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...

  • Given the following code: public static void foo3(String s) { if (s.length() >0) { System.out.print(s.charAt(s.length() -1));...

    Given the following code: public static void foo3(String s) { if (s.length() >0) { System.out.print(s.charAt(s.length() -1)); foo3(s.substring(0, s.length() -1)); } } What is the output of: foo3(“”); 2, You coded the following in the file Test.java : System.out.println( foo(5)); //more code here public static int foo(int n) //line 9 { if (n = = 0)    return 1; else    System.out.println(n* foo(n-1) ); }                                    //line 15 At compile time, you get the following error: Text.java: 15: missing return statement }                                ...

  • 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...

  • Help getting my code to run. public class BusinessClass { // Length public static double inTOcm(double...

    Help getting my code to run. public class BusinessClass { // Length public static double inTOcm(double inches) { return 2.54 * inches; }public static double inTOmeter(double inches) { return 0.0254 * inches; }public static double inTOft(double inches) { return 0.083333 * inches; }public static double inTOyd(double inches) { return 0.0277778 * inches; }public static double inTOkm(double inches) { return 0.000254 * inches; }public static double ftTOmeter(double feet) { return 0.3048 * feet; }public static double ftTOyd(double feet) { return 0.0003048...

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