Question

In the Quiz class, the foo method has the following API : public static double foo(...

In the Quiz class, the foo method has the following API : public static double foo( int i, string s, char c) how many arguments does foo take? is it 3 right?

What is the output of this code sequence?

int a = Math.min( 5, 8 );

System.out.println( a );

What is the output of this code sequence?

System.out.print( Math.round( 3.5 ) );

What is the output of this code sequence?

double d = Math.pow( 2, 3 );

System.out.println( d );

0 0
Add a comment Improve this question Transcribed image text
Answer #1
  1. public static double foo(int i,String s,char c){}

Ans) Yes

Explanation:
There are 3 formal arguments.
First argument integer data type i
Second argument String object s and
Third argument character data type c

2 .What is the output of this code sequence?

int a=Math.min(5,8);
System.out.print(a);

Output: 5

Explanation: Math.min() returns the smaller of two integer values. Parameters are taken such as int, float, double and long data types. if a negative value and positive value is passed as argument then gives result positive. if both arguments are negative then the number with the higher magnitude is generated.

3. What is the output of this code sequence?

System.out.print(Math.round(3.5));

Output: 4

Explanation: Math.round() function returns the closest long to the argument. hence the result data type is long.

4. What is the output of this code sequence?

double d=Math.pow(2,3);
System.out.println(d);

Output: 8.0

Explanation: Math.pow() function calculate a number raise to the power of the some other number. This function returns double data type. This function accepts two parameters, first parameter is base and second parameter is power. Actually, this function static method on Math class, which means you don not have to instantiate a Math instance to call it.

Add a comment
Know the answer?
Add Answer to:
In the Quiz class, the foo method has the following API : public static double foo(...
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
  • In the Quiz class, the foo method has the following API: public double foo(int i, String...

    In the Quiz class, the foo method has the following API: public double foo(int i, String s, char c) What is the return type of the method foo? Int, Double, Char, String

  • 1) In the Quiz class, the foo method has the following API: public void foo( int...

    1) In the Quiz class, the foo method has the following API: public void foo( int x, String s) Which method call(s) would be correct assuming both a and y are integer values and assuming each statement is complete? a. Quiz q = new Quiz(); a = q.foo( y, “Maybe?” ); b. Quiz q = new Quiz(); q.foo( 1, “Hmmm!” ); c. Quiz q = new Quiz(); Quiz.foo( y, “You think” ); d. Both b and c 2) In the...

  • please evaluate the following code. this is JAVA a. class Car { public int i =...

    please evaluate the following code. this is JAVA a. class Car { public int i = 3; public Car(int i) { this.i = i; } } ... Car x = new Car(7), y = new Car(5); x = y; y.i = 9; System.out.println(x.i); b. class Driver { public static void main(String[] args) { int[] x = {5, 2, 3, 6, 5}; int n = x.length; for (int j = n-2; j > 0; j--) x[j] = x[j-1]; for (int j...

  • What is the output of the following code? class C1 { public double PI=3.1; public void...

    What is the output of the following code? class C1 { public double PI=3.1; public void m1() { System.out.println("M1 of C1"); } } class C2 extends C1 { public double PI=3.14; public void m1() { System.out.println("M1 of C2"); } } public class C { public static void main(String[] args) { C1 obj = new C2(); System.out.print(obj.PI); } } 3.1 3.14 None of the above

  • What is the Java output? Part One: class Driver { public static void main(String[] args) {...

    What is the Java output? Part One: class Driver { public static void main(String[] args) { int a = 5; int b = 3; if (a < b || a * 2 < b) System.out.print(a - b); System.out.print(b + a); } } Part Two: class Driver { public static void main(String[] args) { int a = 5; int b = 8; if (a < b) if (a * 2 < b) System.out.print("foo"); else System.out.print("bar"); else System.out.print("buz"); } }

  • Please Help *Urgent* 1 /* */ 2 public class LabFinal 3 { 4 public static void...

    Please Help *Urgent* 1 /* */ 2 public class LabFinal 3 { 4 public static void main(String[] args) { 5 String mesg = "Try out this String."; 6 char[] hold = mesg.toLowerCase().toCharArray(); 7 int p=0; 8 9 System.out.println(forwardSearch(hold,'s')); //output generated 11 10 System.out.println(forwardSearch(hold,'t')); //output generated 0 11 System.out.println(p=forwardSearch(hold,'t',2)); //output generated 6 12 System.out.println(p=forwardSearch(hold,'t',p+1)); //output generated 8 13 System.out.println(p=forwardSearch(hold,'z')); //output generated -1 14 System.out.println(backwardSearch(hold,'s')); //output generated 13 15 System.out.println(backwardSearch(hold,'t')); //output generated 14 16 System.out.println(p=backwardSearch(hold,'t',13)); //output generated 8 17 System.out.println(p=backwardSearch(hold,'t',p-1)); //output generated...

  • Consider the following Java classes: class A{ public int foo () { return 1; } public...

    Consider the following Java classes: class A{ public int foo () { return 1; } public void message () { System.out.println( "A" + foo()); } } class B extends A { public int foo() {return 2; } } class C extends B { public void message () { System.out.println( "C" + foo()); } } (i) What are the outputs of the following code? (ii) What would be the outputs if Java used static dispatching rather than dynamic dispatching? B b...

  • How can I split this program into two classes? import java.io.*; public class Quiz { static...

    How can I split this program into two classes? import java.io.*; public class Quiz { static LineNumberReader cin = new LineNumberReader(new InputStreamReader(System.in)); public static void main(String[] args) { int score = 0; final int NumberofQuestions = 5; int num;    System.out.println("\nWelcome to CSC 111 Java Quiz\n");    String[][] QandA = { {"All information is stored in the computer using binary numbers: ","true"}, {"The word \"Public\" is a reserved word: ","false"}, {"Variable names may begin with a number: ","false"}, {"Will the...

  • 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”);...

  • 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”); } public...

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