Question

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 Quiz class, the foo method has the following API:

public char foo( int i, String s, double c )

Which method call(s) could be correct assuming a is an int and y is an int and each statement is complete?

a.
Quiz q = new Quiz();
a = Quiz.foo( y, “Maybe?”, 1.0 );
b.

char c = Quiz.foo( 1, “Hmmm!”, 0.1 );

c.
Quiz q = new Quiz();
System.out.println( q.foo( y, “You think.”, 2.0));
d.

All of the above

3)

Class HighClass is included in package users.myclasses . To access any static methods of this class in my application class the following statement would be required at the start of my application.

a.

package users.myclasses.HighClass

b.

include users.myclasses.HighClass

c.

class users.myclasses.HighClass

d.

import users.myclasses.HighClass

4)

In the Quiz class, the foo method has the following API:

public static double foo( float f )

What can you say about the method foo?

a.

it is an instance method

b.

it is a class field

c.

it is a class method

d.

it is an instance variable

5)

To instantiate an object instance of class SimpleDate assuming an overloaded SimpleDate class constructor requiring 3 int parameters exists, which statement(s) could be used to instantiate an object of type SimpleDate?

a.

SimpleDate s1 = SimpleDate(1, 2, 3);

b.

SimpleDate s2 = new SimpleDate(1, 2, 3);

c.

SimpleDate s3 = new SimpleDate();

d.

b and c

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
1) In the Quiz class, the foo method has the following API: public void foo( int...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

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

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

  • 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 Java code: class C { public int foo(C p) { return 1; }...

    Given the following Java code: class C { public int foo(C p) { return 1; } } class D extends C { public int foo(C p) { return 2; } public int foo(D p) { return 3; } } C p = new C(); C q = new D(); D r = new D(); int i = p.foo(r); int j = q.foo(q); int k = q.foo(r); (Remember that in Java every object is accessed through a pointer and that methods...

  • public class F2{ public static int foo(ArrayList<Integer> a) { int sum = 0; for(int i =...

    public class F2{ public static int foo(ArrayList<Integer> a) { int sum = 0; for(int i = 0; i <a.size(); i++){ if(i % 3 == 1) sum += a.get(i); else if(i % 3 == 2) sum -= a.get(i); else sum++; } return sum; } } What do the following method calls return? 1. foo(new ArrayList<>(Arrays.asList(1,2,3,4))) 2. foo(new ArrayList<>()) 3. foo(new ArrayList<>(Arrays.asList(1,2,-3,4325,-2))) 4. foo(new ArrayList<>(Arrays.asList(0,0,0)))

  • Show the analytical time complexity. Show all work. public static void foo(int n, char A, char...

    Show the analytical time complexity. Show all work. public static void foo(int n, char A, char B, char C) {       if (n<=0) return;   // primitive operation       foo(n-2, A, C, B);       for (int i=0; i<n; i++) System.out.println(“n=” + n); // primitive operation       foo(n-2, B, A, C); }

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

  • **JAVA*JAVA Question 1 How many k's values will be printed out? public static void main(Stringl args)...

    **JAVA*JAVA Question 1 How many k's values will be printed out? public static void main(Stringl args) for (int k-1: k10:k if (k8) continue: System.out.println k) Question 2 3.5 pts Analyze the following code. Which one is correct? package p public class A package p2: import p1. public class B extends Af int i- 5 private int j- 10: public A0I public static void main(Stringll args) B b new B0: System.out.println(a.i+", "+ajt", "+b.it""+bj): a.i is printable None of them b.i is...

  • Consider the following methods’ headers: public static int one(int a, char b, double c, String d)...

    Consider the following methods’ headers: public static int one(int a, char b, double c, String d) public static double two(double x, double y) public static char three(int r, int s, char t, double u) Answer the following questions: Q1) What is the signature of method one? Answer: Q2) What is the return type of method two? Answer: Q3) What the formal parameters of method three? Answer: Q4) How many actual parameters are needed to call the method three? Answer: Q5)...

  • Consider the following program: # include <iostream> int x = 3, y = 5; void foo(void)...

    Consider the following program: # include <iostream> int x = 3, y = 5; void foo(void) { x = x + 2; y = y + 4; } void bar(void) { int x = 10; y = y + 3; foo( ); cout << x << endl; cout << y << endl; } void baz(void) { int y = 7; bar( ); cout << y << endl; } void main( ) { baz( ); } What output does this program...

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