Mock Examination WA
Mock Examination WA
Mock Examination WA
A. 0
B. 1
C. 4
D. Compilation error
A. Hello, Alice
B. Hello, Alice. You are 0 years old.
C. Compilation error
D. Hello, Alice. You are years old.
A. 25 30
B. 25 30.25
C. 25 30.25 Compilation error
D. Compilation error
Methods
A. Mammal
B. Canine
C. Compilation error
D. Runtime error
A. 1000.0
B. 0.0
C. Compilation error
D. Runtime error
5. What will be the result of trying to access a private field of a class from
outside the class?
A. The field is accessible if the class is in the same package.
B. The field is accessible if there is a getter method.
C. The field is not accessible and will cause a compilation error.
D. The field can be accessed using reflection.
Encapsulation
A. Parent
B. Child
C. Compilation error
D. Runtime error
A. Animal sound
B. Meow
C. Compilation error
D. Runtime error
5. In Java, how does one call a method from the parent class in a subclass?
A. Using the super keyword.
B. Using the this keyword.
C. Using the parent keyword.
D. Using the base keyword.
Inheritance
Polymorphism
A. Drawing Shape
B. Drawing Circle
C. Compilation error
D. Runtime error
2. What is the output of the following code snippet?
Polymorphism
1. B. Drawing Circle
2. A. Integer: 5 Double: 5.5
Abstraction
A. Woof
B. Compilation error
C. Runtime error
D. No output
4. Which of the following statements about abstract methods is true?
A. Abstract methods must be implemented by subclasses.
B. Abstract methods can have a body.
C. Abstract methods can only be defined in a non abstract class.
D. Abstract methods can be private.
Abstraction