Question

1_ What is the output? private void btnMethods_Click(object sender, EventArgs e) { int arg1 = 2;...

1_ What is the output?

private void btnMethods_Click(object sender, EventArgs e)

{

int arg1 = 2;

double val = ValReturnMethod(arg1, 2.00);

MessageBox.Show(val.ToString());

}

private void ValReturnMethod(int val, double val2)

{

return val1 * val2 *25.50;

}

_____________________________

2_ What is the output?

private void btnMethods_Click(object sender, EventArgs e)

{

int arg1 = 4;

double val = ValReturnMethod(ref arg1);

MessageBox.Show(arg1.ToString());

}

private double ValReturnMethod(ref int val1)

{

return val1 *25.50;

}

______________________________

3_ What is the output?

private void btnMethods_Click(object sender, EventArgs e)

{

int arg1 = 4;

double arg2 = 10.50;

MessageBox.Show(ValReturnMethod(arg1,arg2).ToString());

}

private double ValReturnMthod (int val1,double val2)

{

return val1 * 25.50;

}

___________________________

This is not C++ it is Visual C#

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1_ What is the output?

Answer: Code will not compile because we dont have return type in method header private void ValReturnMethod(int val, double val2)

it should be private doubleValReturnMethod(int val, double val2)

2_ What is the output?

Answer: 102

Since we are passing arg1 value as reference. The changes happend on that variable in function will reflect in actual copy of that variable. So arg1 value will display as 102.

3_ What is the output?

Answer: 102

Though w are passing arg1 and arg2 values, but we are suing arg1 value for calculation so arg1 value is 4 here.

4 * 25.50 = 102.

Add a comment
Know the answer?
Add Answer to:
1_ What is the output? private void btnMethods_Click(object sender, EventArgs e) { int arg1 = 2;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Public Class Form1     Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click         Dim...

    Public Class Form1     Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click         Dim room As Double 'Assigns room as double         Dim rate As Double 'Assigns rate as double         Dim room2 As Double 'Assigns room as double         Dim overallRate As Double 'Assigns overall as double         Dim a As Integer 'Assign a as an integer         For a = 1 To 8 'Assign a as an 1 to 8 for all 8 floors             With...

  • Here is my code to insert data into a database. code: private void button2_Click(object sender, EventArgs...

    Here is my code to insert data into a database. code: private void button2_Click(object sender, EventArgs e) { //Insert Button string connString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source = C:\project\patientDB.accdb"; OleDbConnection connection = new OleDbConnection(connString); OleDbCommand cmd = connection.CreateCommand(); cmd.CommandText = "insert into Medical ([PatientID],[GeneralMedicalHistoryID],[Education] values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "' )"; connection.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Record Inserted"); connection.Close(); } However it says syntax error in INSERT statement when I try to add. What am...

  • UI: Provided Code: Public Class Form1 Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click...

    UI: Provided Code: Public Class Form1 Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub Private Sub btnCalculateDueDays_Click(sender As Object, e As EventArgs) Handles btnCalculateDueDays.Click End Sub End Class tick bitwise Or operation Work with dates and times Exercise 9-1 In this exercise, you'll use the Date Time and TimeSpan st I. Open the application th ructures. n that's in the CIVB 2015iChapter 09DateHandlin a form that accepts a future date a directory. Within this project,...

  • Java. What is the output of this code? Ace.java public class Ace { private double a;...

    Java. What is the output of this code? Ace.java public class Ace { private double a; public Ace ( double x) {       a = x; } public void multiply (double f) {       a *= x;         } public String toString () {       return String.format ("%.3f", x); AceDem.java public class AceDemo { public static void main(String args[]) {    Ace card = new Ace (2.133); card.multiply (.5); System.out.println (card); } }

  • E 4 (4 pts.Determine the output of the program helow. impon util. public class ForEachFun output private int public...

    E 4 (4 pts.Determine the output of the program helow. impon util. public class ForEachFun output private int public ForEach unir 5 % 2:1 public v number1 ng toStringO( return mum:) public static void main(String I 1 args) un 1 m-new ForlachFuni4); iE i 3 mil w ForachPun-5) else mf i1 new ForEachFun(8 + i): for (ForEachFun n:m) .number) for (ForEachFun n: m) System.out.printin(n): E 4 (4 pts.Determine the output of the program helow. impon util. public class ForEachFun output...

  • 1. What is the output when you run printIn()? public static void main(String[] args) { if...

    1. What is the output when you run printIn()? public static void main(String[] args) { if (true) { int num = 1; if (num > 0) { num++; } } int num = 1; addOne(num); num = num - 1 System.out.println(num); } public void addOne(int num) { num = num + 1; } 2. When creating an array for primitive data types, the default values are: a. Numeric type b. Char type c. Boolean type d. String type e. Float...

  • Question 19 Given the following class: public class Swapper ( private int x; private String y...

    Question 19 Given the following class: public class Swapper ( private int x; private String y public int z; public Swapper( int a, String b, int c) ( x-a; y b; zC; public String swap() ( int temp -x; x-z z temp; return y: public String tostring() ( if (x<z) return y: else return" +x+z What would the following code output? Swapper r new Suapper( 5, "no", 10); System.out.printin( r. swap ) ): no no510 510 e 15 Question 20...

  • How can I add this function to my C# code?: Validate that if the user clicks...

    How can I add this function to my C# code?: Validate that if the user clicks the “OK” button, a “Seating Category” is selected, and at least one ticket is being purchased. If not, pop-up a dialog box asking the user to enter the needed data for the transaction. What we want to avoid is depicted in See Figure 3. Figure 3: This code asks for a seating category to be selected, how many tickets to be purchased, and if...

  • 1. What is the output? System.out.print(3 + 3 * 3); a. 18 b. 12 c. 9 d. 0 e. 10             2.   What is output by the code below? System.out.print("\\dog\\cat&#...

    1. What is the output? System.out.print(3 + 3 * 3); a. 18 b. 12 c. 9 d. 0 e. 10             2.   What is output by the code below? System.out.print("\\dog\\cat"); a. dog b. dogcat c. \\dog\\cat d. \dog\cat e. catdog\\\\             3.   What is returned by the call     getIt(9) ? public static int getIt(int num){ int ans = 0; if( num >=2 ) {      if( num >= 7)         ans += 2;      else         ans += 3; } ans += 4; return ans; }...

  • For Questions 1-3: consider the following code: public class A { private int number; protected String...

    For Questions 1-3: consider the following code: public class A { private int number; protected String name; public double price; public A() { System.out.println(“A() called”); } private void foo1() { System.out.println(“A version of foo1() called”); } protected int foo2() { Sysem.out.println(“A version of foo2() called); return number; } public String foo3() { System.out.println(“A version of foo3() called”); Return “Hi”; } }//end class A public class B extends A { private char service; public B() {    super();    System.out.println(“B() called”);...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT