2 Marks Questions
Question 1 : State the Java concept that is implemented through;
a) A superclass and a subclass
b) The act of representing essential features without including background details.
Answer : a) The subclass just use the items inherited from its superclass as it is, or the subclass can modify or override it, this process is known as inheritance. In inheritance, superclass is called as parent class and subclass is called as child class.
Question 2 : Define the term bytecode.
Answer : Bytecode is a form of instruction set, designed for efficient execution by a software interpreter as well as being suitable for further compilation into machine code.
Question 3 : What do yo understand by the term data abstraction? Explain with an example.
Answer : Data abstraction apply a clear separation between the abstract properties of a data type and the concrete details of its implementation. The abstracted properties are visible to user that make the use of data type, while the concrete implementation is kept entirely private.
For example, In a mobile , buttons are visible but the circuit of mobile is not visible.
Question 4 : What is inheritance and how it is useful in Java?
Answer : Inheritance in Java is a capability of one class (child class) to inherit the properties of other class (parent class) in terms of parent class (super class) and child class (sub class).
Question 5 : Differentiate between base class and derived class.
Answer : Difference between base class and derived class:
|Base Class||Derived Class|
|A base class facilitates the creation of other class.||Derived class uses the functionality of base class.|
|It is also known as parent/superclass.||It is also known as child/subclass.|
Question 6 : Name two types of Java programs.
Answer : a) Applets
b) Stand-alone applications
Question 7 : Which OOP principle implements function overloading?
Answer : Function overloading or Method overloading is a feature that allows creating several methods with the same name, which differ from each other in the type. It is provided in OOP’s by polymorphism.
Question 8 : Define encapsulation.
Answer : Encapsulation is the technique of making the fields private or public in a class. It is a process of wrapping up the data and function together as a single unit, which is known as class.
Question 9 : Name any two OOP’s principles.
Answer : Any two OOP’s principles are:
Question 10 : How is encapsulation implemented in Java?
Answer : Encapsulation is the technique of making the fields private or public in a class and providing access to the fields via public or private methods. If a field is declared private, it cannot be accessed by anyone outside the class. In Java, it is implemented by the use of a class. A class bind the methods and data together.
Question 11 : Is is possible that an object has more than one abstractions?
Answer : Yes, it is possible for an object to have more than one abstractions. Abstractions in Java is achieved by using interface and abstract class in Java.
Question 12 : What is the need of JVM?
Answer : Java Virtual Machine (JVM) is a virtual machine ( a program) that executes Java bytecode.
Question 13 : How does Java complete its program?
Answer : The compiler itself works as a native executable code (javac.exe), it transforms source file into bytecode then the JVM, which is platform-dependent, translates it into machine code.