Java Assignment (Exam-Oriented) - Answers with
Diagrams
Section A: Short Answer Questions
1. Java is a high-level, object-oriented programming language used to build applications. It is
platform-independent due to JVM.
2. JVM executes Java bytecode, JRE provides runtime environment, and JDK is a development kit
that includes JRE and development tools.
3. Compiled languages convert code into machine code before execution, while interpreted
languages execute code line-by-line.
4. Variables store data values. Types include local, instance, and static variables.
5. Data types define the type of data. They are primitive (int, float, etc.) and non-primitive (arrays,
objects).
6. Operators perform operations. Types include arithmetic, relational, logical, and assignment.
7. Type casting converts one data type to another. It can be implicit (automatic) or explicit (manual).
8. A class is a blueprint for creating objects, and an object is an instance of a class.
9. A method is a function in Java that includes a return type, method name, and parameters.
10. A constructor initializes objects. Types include default and parameterized constructors.
Section B: Long Answer Questions
1. Object-Oriented Programming (OOP) concepts include: Encapsulation, Inheritance,
Polymorphism, and Abstraction.
2. Inheritance allows one class to acquire properties and methods of another class. Types include
single, multilevel, and hierarchical inheritance.
3. Polymorphism allows methods to behave differently. Types: compile-time (overloading) and
runtime (overriding).
4. Encapsulation binds data and methods, while abstraction hides implementation details.
Diagram: JDK Structure
JDK
JRE
JVM
JDK contains JRE, and JRE contains JVM.
Diagram: OOP Concepts
OOP
Encapsulation Inheritance
Polymorphism Abstraction