with Certified Solutions
Which of the following correctly defines an abstract class in Java?
A. `abstract class Vehicle {}`
B. `class abstract Vehicle {}`
C. `Vehicle abstract class {}`
D. `@Abstract Vehicle {}`
✔✔ A. `abstract class Vehicle {}`
Which of the following keywords is used to prevent a method from being overridden?
A. static
B. final
C. abstract
D. private
✔✔ B. final
Which operator is used for bitwise AND in Java?
A. &
1
,B. &&
C. |
D. ^
✔✔ A. &
Which method is called automatically when an object is created?
A. finalize()
B. constructor
C. start()
D. init()
✔✔ B. constructor
Which Java package contains the Scanner class?
A. java.io
B. java.net
C. java.util
D. java.lang
✔✔ C. java.util
2
,Which of the following statements about Java interfaces is true?
A. Interfaces can have constructors
B. Interfaces can contain instance variables
C. Interfaces can have static methods
D. Interfaces can be instantiated directly
✔✔ C. Interfaces can have static methods
Which of the following correctly declares a Java generic class?
A. `class Box<T> {}`
B. `class Box<> {}`
C. `generic class Box<T> {}`
D. `class Box{T} {}`
✔✔ A. `class Box<T> {}`
Which of the following is NOT a valid Java identifier?
A. _variableName
B. 123variable
3
, C. variable_123
D. $variable
✔✔ B. 123variable
Which keyword is used to inherit a class in Java?
A. implements
B. extends
C. inherits
D. override
✔✔ B. extends
Which of the following is a valid return type for a Java method?
A. method
B. void
C. return
D. static
✔✔ B. void
4