UNIT I JAVA
UNIT I JAVA
5-Mark Questions
1. Explain the history of Java and its significance in modern
programming.
o Discuss the origin of Java, its evolution, and its primary features
such as platform independence, object-orientation, and simplicity.
Highlight its major milestones, including the release of Java 1.0,
Java 2, and the transition to the current versions of Java.
2. Explain the architecture of JVM and its components.
o Define the Java Virtual Machine (JVM) and explain its components
like the class loader, runtime data areas, execution engine, and
garbage collector. Discuss how JVM enables Java’s platform
independence and ensures code execution on any device.
3. What is type casting in Java? Explain the differences between
implicit and explicit casting.
o Provide examples of both types of casting and explain when and
how each is used. Discuss automatic promotion of smaller data
types to larger ones (implicit) and manual casting (explicit).
4. What are static variables, methods, and blocks in Java? Provide
examples of their use.
o Discuss the concept of static variables and methods, including their
lifecycle and how they differ from instance members. Explain
static blocks and their role in initialization.
5. Explain the difference between String and StringBuffer in Java.
o Discuss the immutability of String and the mutability of
StringBuffer. Explain the performance benefits of using
StringBuffer for string manipulations and the scenarios where each
should be used.
10-Mark Questions
1. Discuss the object-oriented principles in Java with examples.
o Explain the four main principles of OOP: Encapsulation,
Abstraction, Inheritance, and Polymorphism. Provide examples for
each and demonstrate how these principles help in designing
maintainable and reusable code in Java.
2. Describe the scope and lifetime of variables in Java. How do local,
instance, and static variables differ in terms of scope and lifetime?
o Explain the scope and lifetime of local, instance, and static
variables with examples. Discuss how these variables are created
and destroyed during program execution, and the impact of
their scope on access.
3. Write a Java program to demonstrate the usage of constructors and
methods.
o Write a program that defines a class with both parameterized and
default constructors, and methods for performing operations.
Provide examples that show the constructor and method usage in
object creation and manipulation.
4. Explain the control statements in Java (if, switch, for, while, do-
while) with examples.
o Provide detailed examples of each control statement (if, switch, for
loop, while loop, and do-while loop). Discuss their syntax, usage,
and differences.
5. What are arrays in Java? Explain the differences between one-
dimensional and multi-dimensional arrays with examples.
o Define arrays and explain the process of declaring, initializing, and
accessing elements in one-dimensional and multi-dimensional
arrays. Provide examples for both types of arrays.