Java Programming - Exam Notes
UNIT-I: Introduction to Java Programming
1. What is Java? Explain its features.
Java is a high-level, object-oriented programming language. Features: Platform-independent, Secure, Robust,
Multi-threaded, Portable.
2. How do you write a basic Java program?
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
3. Difference between compiling and running a Java program:
- Compiling: Converts source code to bytecode using javac.
- Running: Uses java to run bytecode on the JVM.
UNIT-II: Data Types and Strings
1. Java primitive types: byte, short, int, long, float, double, char, boolean.
2. Difference between primitive and reference types:
- Primitive stores values.
- Reference stores addresses of objects.
Java Programming - Exam Notes
3. String vs new String():
- "Java" uses string pool.
- new String("Java") creates a new object.
4. String memory management:
Java uses a String Pool in heap memory for unique literals.
UNIT-III: Classes, Methods, and Control Structures
1. What is Inheritance?
Inheritance allows a class to inherit properties and methods from another class.
2. Declaring and invoking methods:
public int add(int a, int b) { return a + b; }
int result = add(10, 20);
3. Loop types:
- For loop: for(int i=0; i<5; i++)
- While loop: while(i < 5)
- Do-while: do { } while(i < 5);
4. Control statements:
- if, if-else, switch, break, continue, return
UNIT-IV: GUI and Client/Server Concepts
Java Programming - Exam Notes
1. What is AWT?
Java's API for GUI development.
2. GUI with AWT example:
Frame, Button, setBounds, setSize, setLayout, setVisible.
3. Client-side vs Server-side scripting:
- Client: JavaScript
- Server: Servlets, ASP
4. What is HTTP?
HTTP is a protocol for data transfer on the web using request-response.