3 - Object Oriented Programming Using Java
3 - Object Oriented Programming Using Java
3 - Object Oriented Programming Using Java
1. What is the mechanism by which one class acquires the properties (methods and fields) of
another class?
a) Inheritance
b) Polymorphism
c) Encapsulation
d) Abstraction
Answer: a) Inheritance
5. In Java, which keyword is used to refer to the current instance of the class?
a) this
b) super
c) self
d) me
Answer: a) this
Answer: A) Public
Answer: C) extends
Answer: C) Compilation
17.What is encapsulation in Java?
A) The process of wrapping code and data together into a single unit
B) The ability of a class to extend more than one class
C) A technique to define different methods of the same class
D) The mechanism of linking a function with an object
Answer: A) The process of wrapping code and data together into a single unit
Answer: A) An abstract class can have concrete methods, while an interface cannot.
Answer: A) final
```java
class Test {
public static void main(String[] args) {
String str = "Hello";
str.concat(" World");
System.out.println(str);
}
}
```
A) Hello
B) World
C) Hello World
D) Compile-time error
Answer: A) Hello
Answer: C) Overridden methods cannot throw checked exceptions that are broader than those
thrown by the original method.
30.What is the purpose of the "this" keyword in Java?
A) To refer to the current class instance
B) To call the superclass constructor
C) To create a new instance of a class
D) To access static variables
34. In Java, what does the "final" keyword signify when applied to a method?
a) The method cannot be overridden
b) The method cannot be accessed
c) The method cannot have parameters
d) The method cannot be called
Answer: a) The method cannot be overridden
38. Which keyword is used to access the superclass's members within a subclass?
a) parent
b) super
c) this
d) extend
Answer: b) super