FULL JAVA PROGRAMMING LANGUAGE NOTES
Complete theory + exam + interview oriented notes
1. Introduction to Java
Java is a high-level, object-oriented, secure and platform-independent programming language
developed by Sun Microsystems (now Oracle). Java follows the principle of WORA (Write Once,
Run Anywhere). Java programs are compiled into bytecode which runs on JVM.
Features of Java
• Object Oriented
• Platform Independent
• Secure & Robust
• Multithreaded
• High Performance
• Distributed
2. JVM, JRE and JDK
JVM (Java Virtual Machine): Executes bytecode and provides runtime environment.
JRE (Java Runtime Environment): JVM + libraries.
JDK (Java Development Kit): JRE + development tools (javac, java).
3. Data Types
Primitive Data Types: byte, short, int, long, float, double, char, boolean.
Non-Primitive Data Types: String, Array, Class, Interface.
4. Variables
Types of Variables:
• Local Variable – declared inside method
• Instance Variable – declared inside class
• Static Variable – declared using static keyword
5. Operators
Arithmetic, Relational, Logical, Assignment, Unary, Bitwise, Ternary.
6. Control Statements
Decision Making: if, if-else, switch
Looping: for, while, do-while
Jump: break, continue, return
7. Arrays
Array is a collection of similar data types stored in contiguous memory locations.
Single Dimensional and Multidimensional arrays are supported.
8. Strings
String is immutable in Java.
StringBuilder – mutable, non-thread safe.
StringBuffer – mutable, thread safe.
9. Object Oriented Programming Concepts
Class, Object, Encapsulation, Inheritance, Polymorphism, Abstraction.
Encapsulation
Wrapping data and methods into a single unit and data hiding using private keyword.
Inheritance
Mechanism of acquiring properties of parent class using extends keyword. Types: Single,
Multilevel, Hierarchical.
Polymorphism
Compile-time: Method Overloading.
Runtime: Method Overriding.
Abstraction
Hiding implementation details using abstract class or interface.
10. Interface
Interface supports multiple inheritance.
Methods are public abstract by default.
Variables are public static final.
11. Constructors
Constructor is used to initialize object.
Types: Default, Parameterized, Copy Constructor.
12. Important Keywords
this, super, static, final, abstract, synchronized.
13. Exception Handling
Handled using try, catch, finally, throw, throws.
Types: Checked and Unchecked exceptions.
14. Multithreading
Thread can be created using Thread class or Runnable interface. start() creates new thread, run()
executes code.
15. File Handling
File class, FileReader, FileWriter, BufferedReader, BufferedWriter.
16. Collections Framework
List: ArrayList, LinkedList
Set: HashSet, TreeSet
Map: HashMap, TreeMap
17. Wrapper Classes
Convert primitive data types into objects.
18. Java 8 Features
Lambda Expressions, Stream API, Functional Interfaces.
19. Important Interview Points
• Java is platform independent but JVM is platform dependent.
• == compares reference, equals() compares content.
• ArrayList faster than LinkedList for searching.