6.3 |
Which statements are true? Select the two correct answers.
|
6.4 |
Given the following classes and declarations, which statements are true? // Classes class Foo { private int i; public void f() { /* ... */ } public void g() { /* ... */ } } class Bar extends Foo { public int j; public void g() { /* ... */ } } // Declarations: // ... Foo a = new Foo(); Bar b = new Bar(); // ... Select the three correct answers.
|
6.5 |
Which statement is true? Select the one correct answer.
|
6.6 |
Given classes A, B, and C, where B extends A, and C extends B, and where all classes implement the instance method void doIt(). How can the doIt() method in A be called from an instance method in C? Select the one correct answer.
|
6.7 |
What would be the result of attempting to compile and run the following code? // Filename: MyClass.java public class MyClass { public static void main(String[] args) { C c = new C(); System.out.println(c.max(13, 29)); } } class A { int max(int x, int y) { if (x>y) return x; else return y; } } class B extends A{ int max(int x, int y) { return super.max(y, x) - 10; } } class C extends B { int max(int x, int y) { return super.max(x+10, y+10); } } Select the one correct answer.
|
6.8 |
Given the following code, which is the simplest print statement that can be inserted into the print() method? // Filename: MyClass.java public class MyClass extends MySuperclass { public static void main(String[] args) { MyClass object = new MyClass(); object.print(); } public void print() { // INSERT CODE HERE THAT WILL PRINT // THE "Hello, world!" STRING FROM THE Message // CLASS. } } class MySuperclass { Message msg = new Message(); } class Message { // The message that should be printed: String text = "Hello, world!"; } Select the one correct answer.
|