Question: Consider the following incomplete class: public class SomeClass { public static final int VALUE1 = 30; public static int value2 = 10; private int value3
Consider the following incomplete class:
public class SomeClass { public static final int VALUE1 = 30; public static int value2 = 10; private int value3 = 5; private double value4 = 3.14; public static void someMethod() { // implementation not shown } public void someOtherMethod() { // implementation not shown } }
Which of the following is a class constant? (2 points)
Question 1 options:
| |||
| |||
| |||
| |||
|
Consider the following incomplete class:
public class SomeClass { public static final int VALUE1 = 30; public static int value2 = 10; private int value3 = 5; private double value4 = 3.14; public static void someMethod() { // implementation not shown } public void someOtherMethod() { // implementation not shown } }
The variable value2 is defined as static. This means: (2 points)
Question 2 options:
| |||
| |||
| |||
| |||
|
Consider the following incomplete class:
public class SomeClass { public static final int VALUE1 = 30; public static int value2 = 10; private int value3 = 5; private double value4 = 3.14; public static void someMethod() { // implementation not shown } public void someOtherMethod() { // implementation not shown } }
The method someOtherMethod is not defined as static. This means: (2 points)
Question 3 options:
| |||
| |||
| |||
| |||
|
Consider the following client code in and assume that it compiles correctly:
public class MainClass { public static void main(String[] args) { SomeClass myObject = new SomeClass(4, 5); int fred = SomeClass.SOME_VALUE; int barney = myObject.method1(); int wilma = SomeClass.method2(4); } }
Which of the following is a static variable or constant? (2 points)
Question 4 options:
| |||
| |||
| |||
| |||
|
What is output by the following code: (2 points)
ArrayList < Integer > a = new ArrayList < Integer >(); ArrayList b = a; a.add(new Integer(4)); b.add(new Integer(5)); a.add(new Integer(6)); System.out.println(a.size());
Question 5 options:
| |||
| |||
| |||
| |||
|
Consider the following code:
ArrayList < Integer > a = new ArrayList < Integer >(); int value; a.add(4); a.add(5); a.add(new Integer(6)); value = a.size(); System.out.println(value);
What happens when this code is compiled?(2 points)
Question 6 options:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Which of the following describes an overridden method? (2 points) Question 7 options:
The process of determining which method in a class hierarchy should execute is known as: (2 points) Question 8 options:
Consider the following code: public class A1 { public int x; private int y; ... } public class A2 extends A1 { public int a; private int b; ... } public class A3 extends A2 { private int q; ... } Which of the following sets of instance variables are directly accessible in class A3? (2 points) Question 9 options:
Consider the following code: public class A1 { public int x; private int y; ... } public class A2 extends A1 { public int a; private int b; ... } public class A3 extends A2 { private int q; ... } Which of the following is true regarding the use of instance variable y in class A1? (2 points) Question 10 options:
Consider the following code: public class B1 { private int i; private int j; ... } public class B2 extends B1 { private int m; private int n; ... } public class B3 extends B2 { private int z; ... } Which of the following sets of instance variables are directly accessible in class B2? (2 points) Question 11 options:
Consider the following code: public class B1 { private int i; private int j; ... } public class B2 extends B1 { private int m; private int n; ... } public class B3 extends B2 { private int z; ... } Which of the following sets of instance variables are directly accessible in class B3? (2 points) Question 12 options:
|
|
All classes in Java are directly or indirectly subclasses of the _______ class. (2 points)
Question 13 options:
| |||
| |||
| |||
| |||
|
Assume that Student and Employee are all extended classes of Person. 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 p2 = new Student(); m2 = p2.getMoney(); // assignment 2 p3 = new Employee(); m3 = p3.getMoney(); // assignment 3
The reference to getMoney() in assignment 3 is to the ________ class (2 points)
Question 14 options:
| |||
| |||
| |||
| |||
|
Assume that Student and Employee are all extended classes of Person. 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 p2 = new Student(); m2 = p2.getMoney(); // assignment 2 p3 = new Employee(); m3 = p3.getMoney(); // assignment 3
The reference to getMoney() in assignment 2 is to the ________ class (2 points)
Question 15 options:
| |||
| |||
| |||
| |||
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
