Checked and unchecked exceptions

In Java, exceptions are broadly divided into three main categories, based on how the compiler and runtime handle them: 1. Checked Exceptions Definition: Exceptions that are checked at compile-time. If your code might throw a checked exception, you must either handle it with a try-catch block or declare it with throws. These are typically…

0 Comments

Nested and Inner Classes

1. Nested Classes in Java A nested class is any class defined inside another class. Java allows classes to be nested for better organization, encapsulation, and readability. There are two main types: A. Static Nested Class Declared static inside another class. Can access only static members of the outer class directly. Does not have…

0 Comments

Java’s history

Java’s history is a mix of big ideas, clever engineering, and a little bit of luck. Here’s the story in a clear timeline form: 1. Origins (1991–1994) – The Green Project In 1991, a small team at Sun Microsystems led by James Gosling, Patrick Naughton, and Mike Sheridan started the Green Project. The original…

0 Comments

Java Versions

YearVersionKey Features1996JDK 1.0First official release; basic core libraries, applets.1997JDK 1.1Inner classes, JDBC, JavaBeans, RMI.1998J2SE 1.2Swing GUI, Collections Framework, JIT compiler.2000J2SE 1.3HotSpot JVM, Java Naming and Directory Interface (JNDI).2002J2SE 1.4assert keyword, NIO (New I/O), logging API, XML parsing.2004J2SE 5.0Generics, annotations, enhanced for loop, autoboxing, varargs.2006Java SE 6Scripting API, improvements in web services, compiler API.2011Java SE…

0 Comments

JVM JDK JRE

1. JVM (Java Virtual Machine) Definition: JVM is the engine that runs Java bytecode. Role: It converts compiled Java bytecode into machine code so your program can run on any device. Key Point: JVM is platform-dependent (different JVMs exist for Windows, Linux, Mac). Example: You write code once, compile it, and JVM allows it…

0 Comments

Access modifiers in Java

In Java, access specifiers (also called access modifiers) define the visibility and accessibility of classes, methods, variables, and constructors. They control which parts of a program can access certain members of a class. Java has four main access specifiers: 1. public Visibility: Everywhere, i.e., from any other class or package. Usage: When you want…

0 Comments

Abstraction in java

In Java, abstraction is the process of hiding the implementation details of a class or method and exposing only the essential features to the outside world.It lets you focus on what an object does rather than how it does it. Why Abstraction? Reduces complexity by hiding unnecessary details. Increases flexibility — implementation can change…

0 Comments

Inheritance in Java

1. What is Inheritance? Inheritance is a mechanism in Java by which one class (child/subclass) can acquire the properties (fields) and behaviors (methods) of another class (parent/superclass). It promotes code reusability and method overriding. 2. Types of Inheritance in Java Java supports several types of inheritance: Single Inheritance A class inherits from one parent…

0 Comments

Encapsulation in Java

1. What is Encapsulation? Encapsulation is a mechanism of wrapping data (variables) and methods (functions) together into a single unit, typically a class, and restricting direct access to some of the object's components. This is done to protect the internal state of the object and ensure controlled access. Think of it as a capsule:…

0 Comments

Java keywords static, final, super, and this

1. static Purpose: Makes a member (variable or method) belong to the class rather than an instance. Usage: Static variable: shared across all instances of the class. Static method: can be called without creating an object. Example: class Example { static int count = 0; // shared by all objects static void showCount() {…

0 Comments

End of content

No more pages to load