Filters
Question type

Study Flashcards

What is wrong with the following code? Public class ClassB extends ClassA { Public ClassB() { Super(40) ; System.out.println("This is the last statement " + "in the constructor.") ; } }


A) Nothing is wrong with the code.
B) The method super is not defined.
C) The call to the method super must be the first statement in the constructor.
D) No values may be passed to super.

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

A functional interface is simply an interface that has one abstract method.

A) True
B) False

Correct Answer

verifed

verified

If a class contains an abstract method:


A) you cannot create an instance of the class
B) the method will have only a header, but not a body, and end with a semicolon
C) the method must be overridden in subclasses
D) All of the above

E) A) and C)
F) None of the above

Correct Answer

verifed

verified

The super statement that calls the superclass constructor:


A) must be the first statement in the superclass's constructor
B) can appear in any method of the subclass
C) must be the first statement in the subclass's constructor
D) is deprecated and is no longer supported in newer versions of Java

E) A) and B)
F) B) and D)

Correct Answer

verifed

verified

Look at the following code. Which line in ClassA has an error? Line 1 public interface MyInterface Line 2 { Line 3 int FIELDA = 55; Line 4 public int methodA(double) ; Line 5 } Line 6 public class ClassA implements MyInterface Line 7 { Line 8 FIELDA = 60; Line 9 public int methodA(double) { } Line 10 }


A) 6
B) 7
C) 8
D) 9

E) B) and C)
F) A) and C)

Correct Answer

verifed

verified

If a class contains an abstract method:


A) you must create an instance of the class
B) the method will have only a header, but not a body, and end with a semicolon
C) the method cannot be overridden in subclasses
D) All of the above.

E) A) and B)
F) A) and D)

Correct Answer

verifed

verified

Which of the following statements correctly specifies three interfaces?


A) public class ClassA implements Interface1, Interface2, Interface3
B) public class ClassA implements [Interface1, Interface2, Interface3]
C) public class ClassA implements (Interface1, Interface2, Interface3)
D) public class ClassA implements Interface1 Interface2 Interface3

E) None of the above
F) A) and D)

Correct Answer

verifed

verified

When an "is a" relationship exists between objects, it means that the specialized object has:


A) some of the characteristics of the general class, but not all, plus additional characteristics
B) some of the characteristics of the general object, but not all
C) none of the characteristics of the general object
D) all the characteristics of the general object, plus additional characteristics

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

Like a family tree, a ________ shows the inheritance relationship between classes.


A) flowchart
B) class map
C) class hierarchy
D) binary tree

E) None of the above
F) All of the above

Correct Answer

verifed

verified

In the following statement, which is the superclass? Public class ClassA extends ClassB implements ClassC


A) ClassA
B) ClassB
C) ClassC
D) Cannot tell

E) A) and D)
F) B) and C)

Correct Answer

verifed

verified

Which of the following is an example of a lambda expression?


A) int x = x * factor;
B) IntCalculator = new divider(x, 2) ;
C) IntCalculator multiplier = x -> x * factor;
D) All of the above

E) A) and B)
F) All of the above

Correct Answer

verifed

verified

Look at the following code. Which line will cause a compiler error? Line 1 public class ClassA Line 2 { Line 3 public ClassA() {} Line 4 public int method1(int a) {} Line 5 public final int method2(double b) {} Line 6 } Line 7 public ClassB extends ClassA Line 8 { Line 9 public ClassB() {} Line 10 public int method1(int b) {} Line 11 public int method2(double c) {} Line 12 }


A) 4
B) 5
C) 10
D) 11

E) None of the above
F) All of the above

Correct Answer

verifed

verified

All fields declared in an interface:


A) are final and static
B) have protected access
C) must be initialized in the class implementing the interface
D) have private access

E) None of the above
F) C) and D)

Correct Answer

verifed

verified

This is a special type of expression used to create an object that implements a functional interface.


A) lambda
B) beta
C) alpha
D) sigma

E) A) and B)
F) C) and D)

Correct Answer

verifed

verified

Protected members are:


A) not quite private
B) not quite public
C) both A and B
D) neither A nor B

E) All of the above
F) A) and B)

Correct Answer

verifed

verified

Look at the following code. Line 1 public class ClassA Line 2 { Line 3 public ClassA() {} Line 4 public void method1(int a) {} Line 5 } Line 6 public class ClassB extends ClassA Line 7 { Line 8 public ClassB() {} Line 9 public void method1() {} Line 10 } Line 11 public class ClassC extends ClassB Line 12 { Line 13 public ClassC() {} Line 14 public void method1() {} Line 15 } Which method will be executed as a result of the following statements? ClassB item1 = new ClassA() ; Item1.method1() ;


A) Line 4
B) Line 9
C) Line 14
D) This is an error and will cause the program to crash.

E) C) and D)
F) A) and D)

Correct Answer

verifed

verified

Look at the following code: Line 1 public class ClassA Line 2 { Line 3 public ClassA() {} Line 4 public void method1(int a) {} Line 5 } Line 6 public class ClassB extends ClassA Line 7 { Line 8 public ClassB() {} Line 9 public void method1() {} Line 10 } Line 11 public class ClassC extends ClassB Line 12 { Line 13 public ClassC() {} Line 14 public void method1() {} Line 15 } Which method1 will be executed when the following statements are executed? ClassA item1 = new ClassB() ; Item1.method1() ;


A) Line 4
B) Line 9
C) Line 14
D) This is an error and will cause the program to crash.

E) A) and C)
F) C) and D)

Correct Answer

verifed

verified

Every class has a toString method and an equals method inherited from the Object class.

A) True
B) False

Correct Answer

verifed

verified

An anonymous inner class must:


A) implement an interface
B) extend another class
C) either A or B
D) both A and B

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

Which of the following statements declares Salaried as a subclass of PayType?


A) public class Salaried extends PayType
B) public class Salaried implements PayType
C) public class Salaried derivedFrom(Paytype)
D) public class PayType derives Salaried

E) C) and D)
F) All of the above

Correct Answer

verifed

verified

Showing 41 - 60 of 70

Related Exams

Show Answer