1. Which of the following is not an OOPS concept in Java?
a) inheritance
b) Encapsulation
C) polymorphism
d) Collection
Answer: D
Explanation: Java has 4 OOPS concepts. Inheritance, Encapsulation, Polymorphism and Abstraction.
advertisement
2. Which of the following polymorphisms in Java?
A) Compilation time polymorphism
B) execution time polymorphism
C) multiple polymorphisms
D) multilevel polymorphism
Answer: A
Explanation: There are two types of polymorphisms in Java. Compile time polymorphism (overloading) and runtime polymorphism (overriding).
3. When is method surcharge determined?
a) at run time
B) at compile time
c) at the time of coding
D) at the time of execution
Answer: B
Explanation: Overloading is performed at compile time. Therefore, it is also known as compilation time polymorphism.
4. When there is no overloading?
a) More than one method with same name but different method signatures and different numbers or types of parameters
B) more than one method with same name, same signature but different number of signatures
C) More than one method but different types with parameters of same name, same signature, same number
D) More than one method with different parameters and types of the same name, same number but different signatures.
Answer: D
Explanation: Overloading occurs when more than one method with the same name but different constructors as well as when the same signature but different types of parameters and / or parameter types.
5. Which Java concept is a way to convert real-world objects in terms of class?
a) polymorphism
b) Encapsulation
C) abstraction
D) inheritance
Answer: C
Explanation: Abstraction is the concept of defining real-world objects in terms of classes or interfaces.
6. Which concepts and features of Java are achieved by combining methods and features into one class?
a) Encapsulation
b) inheritance
C) polymorphism
d) abstraction
Answer: A
Explanation: Encapsulation is implemented by combining methods and attribute in a class. The class acts like a container of encapsulating properties.
7. If an object has its own life cycle and no owner, what is it called?
B) composition
c) Encapsulation
d) Association
Answer: D
Explanation: This is a relationship where all things have their own life cycle and there is no owner. This is where multiple relationships are available instead of one to one or several.
8. What is it called where the child object is killed if the parent object is killed?
A) aggregation
B) composition
c) Encapsulation
d) Association
Answer: B
Explanation: Structure occurs when the child object is killed if the parent object is killed. Aggregation is also known as strong aggregation.
9. What is it called where the object has its own life cycle and the child's object cannot be related to any other parent object?
A) aggregation
B) composition
c) Encapsulation
d) Association
Answer: A
Explanation: Aggregation occurs when objects have their own life cycle and the child's object can only associate with one parent object.
10. Method overriding is a combination of inheritance and polymorphism?
A) true
B) false
Answer: A
Explanation: For method overriding, the method with the same signature in both the superclass and the subclass is required. It satisfies both concepts inheritance and polymorphism.
11. Which component is used to compile, debug and execute Java programs?
a) JVM
b) JDK
C) JIT
d) JRE
Answer: B
Explanation: JDK is a core component of the Java environment and provides all the tools, execution, and binaries needed to compile, debug, and execute Java programs.
12. Which component is responsible for converting bytecode to machine specific code?
a) JVM
b) JDK
C) JIT
d) JRE
Answer: A
Explanation: The JVM machine is responsible for converting bytecode to specific code. JVM is also a platform dependent and provides core Java functions such as garbage collection, memory management, security and more.
13. Which component is responsible for running Java programs?
a) JVM
b) JDK
C) JIT
d) JRE
Answer: D
Explanation: JRE is an implementation of JVM, it provides the platform to execute Java programs.
14. Which component is responsible for optimizing biotech for machine code?
a) JVM
b) JDK
C) JIT
d) JRE
Answer: C
Explanation: JIT optimizes bytecodes for machine specific language code by compiling similar bytecodes at the same time. This reduces the overall time taken to compile the bytecode to the machine-specific language.
15. Which statement about Java is correct?
a) Platform independent programming language
B) platform dependent programming language
C) Code dependent programming language
D) sequence dependent programming language
Answer: A
Explanation: Java is called 'Independ Platform Independent Language' because it mainly works on the principle of ile compilation, runs everywhere '.
16. Which of the following is an invalid identifier from the main method?
a) public
b) stable
C) private
d) Final
Answer: C
Explanation: The main method cannot be private because it is implemented by an external method.