CORE JAVA & ADVANCED JAVA Complete
PRA + Viva Notes
1. Introduction to Java
Java is a high-level, object-oriented, secure, and platform-independent programming language
developed by Sun Microsystems and currently maintained by Oracle. Java follows the principle
of Write Once, Run Anywhere (WORA), meaning compiled Java bytecode can run on any
platform that has a compatible Java Virtual Machine (JVM).
Java is widely used for enterprise applications, web applications, mobile applications
(Android), and backend services due to its robustness, security features, and strong memory
management.
1.1 Features of Java
Key features of Java include platform independence, object-oriented nature, robustness,
security, multithreading support, high performance with JIT compiler, distributed computing
capability, and dynamic behavior.
1.2 Java Architecture (JVM, JRE, JDK)
The Java architecture consists of three major components: JVM, JRE, and JDK. JVM executes
bytecode and manages memory. JRE provides libraries and JVM required to run Java
programs. JDK includes JRE along with development tools such as javac, java, javadoc, and
debugger.
2. Object-Oriented Programming (OOP) Concepts
2.1 Encapsulation
Encapsulation is the mechanism of wrapping data (variables) and code (methods) together as
a single unit called class. It helps in data hiding by declaring variables as private and providing
public getter and setter methods.
2.2 Inheritance
Inheritance allows a class to acquire properties and behaviors of another class using the
extends keyword. It promotes code reusability and establishes an IS-A relationship between
parent and child classes.
2.3 Polymorphism
Polymorphism allows one method to perform different behaviors based on object reference.
Compile-time polymorphism is achieved using method overloading, while runtime
polymorphism is achieved using method overriding.
2.4 Abstraction
Abstraction hides implementation details and exposes only essential features. It is achieved
using abstract classes and interfaces.
3. Constructors
Constructors are special methods used to initialize objects. They have the same name as the
class and do not have a return type. Types of constructors include default constructor and
parameterized constructor. Constructor overloading is allowed in Java.
4. Keywords in Java
Important Java keywords include static, final, this, super. Static members belong to the class
rather than objects. Final keyword prevents modification. this refers to current object. super
refers to parent class object.
5. Exception Handling
5.1 Exception Hierarchy
Exceptions in Java are objects that represent abnormal conditions. Throwable is the root class.
Exceptions are divided into checked exceptions and unchecked exceptions.
5.2 try-catch-finally
The try block contains code that may cause an exception. The catch block handles the
exception. The finally block always executes and is used for resource cleanup.
5.3 Custom Exceptions
Custom exceptions are user-defined exceptions created by extending Exception or
RuntimeException classes.
6. Collections Framework
The Java Collections Framework provides a unified architecture for storing and manipulating
groups of objects. It includes interfaces such as List, Set, Queue, and Map.
6.1 List Interface
List allows duplicate elements and maintains insertion order. Common implementations
include ArrayList and LinkedList.
6.2 Set Interface
Set does not allow duplicate elements. Common implementations include HashSet and
TreeSet.
6.3 Map Interface
Map stores data in key-value pairs. Common implementations include HashMap,
LinkedHashMap, and TreeMap.
7. Multithreading
Multithreading allows concurrent execution of multiple threads to improve performance.
Threads can be created by extending Thread class or implementing Runnable interface.
7.1 Thread Lifecycle
Thread lifecycle states include New, Runnable, Running, Waiting, and Terminated.
7.2 Synchronization
Synchronization ensures that only one thread accesses shared resources at a time to avoid
data inconsistency.
8. Java 8 Features
Java 8 introduced functional programming features such as lambda expressions, streams,
functional interfaces, default methods, and Optional class.
9. Advanced Java
9.1 Servlets
Servlets are server-side Java components used to handle client requests and generate
dynamic responses. Servlet lifecycle methods include init(), service(), and destroy().
9.2 JSP
JavaServer Pages (JSP) are used to create dynamic web content. JSP allows embedding
Java code within HTML.
9.3 Session Management
Session management techniques include Cookies, HttpSession, URL Rewriting, and Hidden
fields.
9.4 MVC Architecture
MVC stands for Model-View-Controller. It separates business logic, presentation logic, and
request handling.