Question

Assume that the following code exists inside a method of SomeClass, and that this code compiles...

Assume that the following code exists inside a method of SomeClass,

and that this code compiles without errors:

int result = obj.calculate(4, 3.14);

Which of the following can you know to be true about the calculate method?

1. It is a public method.

2. It is located in SomeClass

3. It is not located in SomeClass

Is it:

-Statement 1 only

-Statement 2 only

-Statement 3 only

-Statement 1 & 2 only

-Statement 1 & 3 only

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

Statement 1 & 2 only

The calculte method is located in someClass and that mehod is public mehod so that it will access another class object.

Add a comment
Know the answer?
Add Answer to:
Assume that the following code exists inside a method of SomeClass, and that this code compiles...
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
  • 10. Recursive Append Download the file AppendRec.java. Write your code inside the appendNTimes method and use...

    10. Recursive Append Download the file AppendRec.java. Write your code inside the appendNTimes method and use the main method to test your code. Submit the file AppendRec.java. There is no need to delete the main method, the autograder will only grade appendNTimes. The method appendNTimes is recursive and takes two arguments, a string and an integer. It returns the original string appended to the original string n times. The method signature is as follows public static String appendNTimes ( String...

  • 1. What is output by the following code: ArrayList< Integer > a = new ArrayList< Integer...

    1. What is output by the following code: ArrayList< Integer > a = new ArrayList< Integer >(); ArrayList b = a; a.add(new Integer(4)); b.add(new Integer(5)); a.add(new Integer(6)); a.add(new Integer(7)); System.out.println(b.size()); A)1 B)2 C)3 D)4 E)5 2. Assume the Student and Employee classes each extend the Person class. The Student class overrides the getMoney method in the Person class. Consider the following code:     Person p1, p2, p3;     int m1, m2, m3;     p1 = new Person();     m1 = p1.getMoney();     // assignment 1...

  • Analyze the following code: class Test ( private int t static int x; public void method()...

    Analyze the following code: class Test ( private int t static int x; public void method() Test test new Test); System.out.println (x); a. The variable t is not initialized and therefore causes er The program compiles fine but has runtime errors because main method. cThe variable t is private and therefore cannot be accessed in t method. The program compiles and runs fine

  • The following piece of code is intended to find the count of negative numbers in the...

    The following piece of code is intended to find the count of negative numbers in the array. The code compiles correctly but it is giving the wrong answer. There are two logic errors in the code causing the incorrect result Identify the lines of code which are giving the incorrect result, re-write the lines of code with the logic errors corrected and give a brief explanation to why they are giving the incorrect result. i int [] list = {-4,...

  • Analyze the following code: public class Test { private int t; public static void main(String[] args)...

    Analyze the following code: public class Test { private int t; public static void main(String[] args) { int x; System.out.println(t); } } t is non-static and it cannot be referenced in a static context in the main method. The program compiles and runs fine. The variable t is not initialized and therefore causes errors. The variable x is not initialized and therefore causes errors.

  • Analyze the following code: public class Test { private int t; public static void main(String[] args)...

    Analyze the following code: public class Test { private int t; public static void main(String[] args) { int x; System.out.println(t); } } The variable t is private and therefore cannot be accessed in the main method. The program compiles and runs fine. t is non-static and it cannot be referenced in a static context in the main method. The variablet is not initialized and therefore causes errors. The variable x is not initialized and therefore causes errors.

  • 1. Analyze the following code: public class Test implements Runnable { public static void main(String[] args) { Thread t = new Thread(this); t.start(); } public void run() { System....

    1. Analyze the following code: public class Test implements Runnable { public static void main(String[] args) { Thread t = new Thread(this); t.start(); } public void run() { System.out.println("test"); } } 1. The code compiles but will not print anything since t does not invoke the run method. 2. The code will not compile since you cannot invoke "this" in a static method. 3. The program compiles, runs, and prints tests on the console. 2. What will the following example...

  • With a Scanner object created as follows, what method do you use to read an int...

    With a Scanner object created as follows, what method do you use to read an int value? Scanner input = new Scanner(System.in); A. input.int(); B. input.nextInt(); C. input.integer(); D. input.nextInteger(); What is the output of the following code? x = 0; if (x > 0) System.out.println("x is greater than 0"); else if (x < 0) System.out.println("x is less than 0"); else System.out.println("x equals 0"); A. x is greater than 0 B. x is less than 0 C. x equals 0...

  • Question 21 Which of the following expression yields an integer between 0 and 100, inclusive? A....

    Question 21 Which of the following expression yields an integer between 0 and 100, inclusive? A. (int)(Math.random() * 100) B. (int)(Math.random() * 101) C. (int)(Math.random() * 100) + 1 D. (int)(Math.random() * 100 + 1 Question 23 The not equal comparison operator in Java is ________. A. != = B. <> C. ^= D. != Question 24 What is the output of the following fragment? for (int i = 0; i < 15; i++) { if (i % 4 ==...

  • (20 pts) Inside a method main, we see code like:      Airplane.foo3(34.6); From this, reconstruct the...

    (20 pts) Inside a method main, we see code like:      Airplane.foo3(34.6); From this, reconstruct the header of method foo3 (which belongs to class Airplane); make appropriate assumptions if necessary. Write the method header as your answer.                (20 pts) Inside method main, we see code like: Airplane a = new Airplane(); int n = a.foo4(“Hello”); From this, reconstruct the header of method foo4 (which belongs to class Airplane) Write the method header as your answer. (40 pts) You coded...

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