1. What is Java? Explain its features.
Java is a high-level, object-oriented programming language developed by Sun Microsystems.
Features:
- Platform Independent
- Object-Oriented
- Robust
- Secure
- Multithreaded
- Portable
- High Performance
Page 1
2. Explain the concept of JDK, JRE, and JVM.
JDK (Java Development Kit): Includes tools for developing Java programs (compiler, debugger).
JRE (Java Runtime Environment): Provides libraries and JVM to run Java programs.
JVM (Java Virtual Machine): Executes Java bytecode on any machine.
Page 2
3. What are data types in Java?
Data types specify the type of data a variable can hold.
- Primitive types: int, float, double, char, boolean, byte, short, long
- Non-primitive types: String, Arrays, Classes, Interfaces
Page 3
4. Explain the concept of type casting in Java.
Type casting is converting one data type into another.
- Implicit (widening): int to float
- Explicit (narrowing): double to int (requires casting)
Page 4
5. What is the difference between == and equals() in Java?
== compares object references (memory location).
equals() compares actual content of objects (e.g., in Strings).
Page 5
6. Explain the concept of inheritance in Java.
Inheritance is a mechanism where one class acquires the properties and behaviors of another.
Uses 'extends' keyword.
Promotes code reusability.
Page 6
7. What is method overloading and method overriding?
Overloading: Same method name with different parameters (within same class).
Overriding: Subclass provides specific implementation of a superclass method.
Page 7
8. What is constructor? Explain its types.
Constructor: Special method used to initialize objects.
Types:
- Default constructor
- Parameterized constructor
Page 8
9. Explain the concept of abstract class and interface.
Abstract class: Contains abstract methods (without body) and concrete methods. Cannot be
instantiated.
Interface: All methods are abstract (till Java 7), used to achieve multiple inheritance.
Page 9
10. What is exception handling in Java?
Exception handling is managing runtime errors using try, catch, throw, throws, and finally.
Ensures program doesn't crash unexpectedly.
Page 10
11. What are packages in Java?
Packages are a way to group related classes and interfaces.
Helps in organizing code and avoiding name conflicts.
Page 11
12. Explain access modifiers in Java.
Access modifiers control the scope of variables, methods, and classes.
Types:
- private
- default
- protected
- public
Page 12