CS180 Final - unit 1
1. What are 4 OOPS concepts in Java?
1. inheritance 2. encapsulation 3. polymorphism 4. abstraction
9. How can we identify whether a compilation unit is class or interface from a .class file?a) Java source file headerb) Extension of compilation unitc) We cannot differentiate between class and interfaced) The class or interface name should be postfixed with unit type
a) Java source file header
4. Which component is responsible to optimize bytecode to machine code?a) JVMb) JDKc) JITd) JRE
JIT (Just-In-Time Compiler)
5. Which concept of Java is a way of converting real world objects in terms of class?a) Polymorphismb) Encapsulationc) Abstractiond) Inheritance
Abstraction is the concept of defining real world objects in terms of classes or interfaces.
9. What is it called where object has its own lifecycle and child object cannot belong to another parent object?a) Aggregationb) Compositionc) Encapsulationd) Association
Aggregation occurs when objects have their own life cycle and child object can associate with only one parent object.
7. What is it called if an object has its own lifecycle and there is no owner?a) Aggregationb) Compositionc) Encapsulationd) Association
Association: No ownership — both objects are independent. Both can exist without each other.
8. What is it called where child object gets killed if parent object is killed?a) Aggregationb) Compositionc) Encapsulationd) Association
Composition occurs when child object gets killed if parent object gets killed.
6. Which concept of Java is achieved by combining methods and attribute into a class?a) Encapsulationb) Inheritancec) Polymorphismd) Abstraction
Encapsulation is implemented by combining methods and attribute into a class.
1. Which component is used to compile, debug and execute java program?a) JVMb) JDKc) JITd) JRE
JDK(Java Development Kit)
3. Which component is responsible to run java program?a) JVMb) JDKc) JITd) JRE
JRE (Java Runtime Environment)
2. Which component is responsible for converting bytecode into machine specific code?a) JVMb) JDKc) JITd) JRE
JVM(Java Virtual Machine)
10. What is use of interpreter?a) They convert bytecode to machine language codeb) They read high level code and execute themc) They are intermediated between JIT and JVMd) It is a synonym for JIT
They read high level code and execute them
2. Which of the following is a type of polymorphism in Java? a) Compile time polymorphism b) Execution time polymorphism c) Multiple polymorphism d) Multilevel polymorphism
a) Compile time polymorphism
5. Which statement is true about java?a) Platform independent programming languageb) Platform dependent programming languagec) Code dependent programming languaged) Sequence dependent programming language
a) Platform independent programming language
3. When does method overloading is determined? a) At run time b) At compile time c) At coding time d) At execution time
b) At compile time
6. Which of the below is invalid identifier with the main method?a) publicb) staticc) privated) final
private