JAVA PROGRAMMING – EXAM ORIENTED NOTES
(CS22409)
UNIT I – INTRODUCTION TO OOP AND JAVA
Object Oriented Programming (OOP) is a programming paradigm based on objects and classes.
Main Concepts:
• Abstraction – Hiding unnecessary details and showing only essential features.
• Encapsulation – Wrapping data and methods into a single unit called a class.
• Inheritance – One class acquires properties of another class.
• Polymorphism – Ability of an object to take many forms.
Java Characteristics:
Simple, Object Oriented, Platform Independent, Secure, Robust, Portable and Multithreaded.
Java Environment:
JDK – Development tools
JRE – Runtime environment
JVM – Executes Java bytecode.
Basic Programming Concepts:
Data types, variables, operators, control statements (if, switch, loops) and arrays are used to build
Java programs.
UNIT II – CLASSES, PACKAGES AND INHERITANCE
Class is a blueprint of objects and contains variables and methods.
Object is an instance of a class.
Constructors:
Used to initialize objects. Types:
• Default constructor
• Parameterized constructor
Access Specifiers:
public, private, protected and default.
Static Members:
Belong to the class rather than objects.
Packages:
Collection of related classes used for organization and avoiding name conflicts.
Inheritance:
Mechanism where child class inherits properties of parent class.
Types: Single, Multilevel and Hierarchical.
Abstract Class:
A class that cannot be instantiated and may contain abstract methods.
Final Keyword:
Used with variables, methods and classes to restrict modification.
UNIT III – INTERFACES, STRINGS AND EXCEPTION HANDLING
Interface:
Contains abstract methods that must be implemented by classes.
Difference:
Class → can have variables and methods.
Interface → only abstract methods.
String Manipulation:
String is a sequence of characters.
Important Methods:
length(), charAt(), substring(), equals(), toUpperCase(), toLowerCase().
Exception Handling:
An exception is an error that occurs during program execution.
try – block containing risky code
catch – handles exception
finally – executes always
User Defined Exception:
Custom exceptions created by programmers.
UNIT IV – I/O STREAMS AND MULTITHREADING
Streams represent flow of data in Java.
Types:
Byte Streams – handle binary data.
Character Streams – handle text data.
File Handling:
FileInputStream – read file
FileOutputStream – write file
Multithreading:
Allows multiple tasks to execute simultaneously.
Advantages:
Better CPU utilization and faster execution.
Thread Creation:
1. Extending Thread class
2. Implementing Runnable interface
Thread Life Cycle:
New → Runnable → Running → Waiting → Terminated.
UNIT V – JAVA APPLET AND JAVAFX
Applet:
Small Java program that runs in a web browser.
Applet Life Cycle:
init() → start() → paint() → stop() → destroy()
JavaFX:
Used for building modern GUI applications.
Features:
• Rich UI components
• Event handling
• Layout management
• Graphics support
Common GUI Controls:
Button, Label, TextField, CheckBox, RadioButton, ListView, ComboBox and Menu.
IMPORTANT EXAM QUESTIONS
1. Explain OOP concepts in Java.
2. Explain the structure of a Java program.
3. What are constructors? Explain types.
4. Explain inheritance with example.
5. Explain interfaces in Java.
6. Explain exception handling with example.
7. Explain string manipulation methods.
8. Explain file streams in Java.
9. Explain multithreading and thread life cycle.
10. Explain Applet life cycle.