Flat Preloader Icon

Threads

Overview Defining Thread Creating & Starting a Thread Thread States Preventing Thread Execution Thread Sleeping Thread priorities Synchronization Thread Interaction In Java, threads are a fundamental part of the language and its libraries, allowing you to create and manage concurrent execution of tasks within a program. Java provides a built-in Thread class and a java.util.concurrent … Read more

Nested Classes

Note:Nested classes, also known as inner classes, are classes defined within the scope of another class. They are a feature found in many object-oriented programming languages like Java, C++, and Python. Nested classes can be useful for organizing and encapsulating code, improving code readability, and reducing namespace pollution. Here’s an overview of nested classes: Overview … Read more

Abstract Classes

Note: Abstract classes are a fundamental concept in object-oriented programming (OOP) languages like Java, C#, and Python. They are used to create classes that cannot be instantiated on their own but serve as blueprints for other classes. Abstract classes are designed to be subclassed, and they often contain one or more abstract methods that must … Read more

What Is An Interface

In object-oriented programming (OOP), an interface is a fundamental concept that defines a contract or a set of abstract methods that a class must implement. An interface, in essence, specifies a list of methods that a class that implements the interface must provide. Interfaces do not contain any actual method implementations; they only declare the … Read more

Classification Of Exceptions

Classification of exceptions Checked Exceptions or compile time exceptions, like IOException, MalformedURLException etc. Compiler forces these exceptions to be caught or passed to calling program Unchecked exceptions or runtime exceptions, like ArithmeticException, ArrayIndexOutofBoundsException etc. Compiler does not force to handle these unchecked exceptions. Throwing exceptions to the caller Using “throws”, the called method can pass … Read more

Exception Handling

Overview What is exception? Constructs to deal with exceptions Classification of exceptions Throwing exceptions to the caller Creating your own exception class. Analyzing the stack trace Exception handling in Java is a mechanism that allows you to gracefully handle unexpected or exceptional situations that may occur during the execution of a program. Exceptions can occur … Read more

Calling Super Class Constructors

Note: In Java, you can call the constructor of the superclass (base class) from a subclass (derived class) constructor using the super keyword. This is often necessary when you want to initialize the inherited members or perform additional setup in the superclass constructor before initializing the subclass-specific members. Here’s how you can call the superclass … Read more

Inheritance, Accessibility & Overriding

Inheritance, accessibility modifiers, and method overriding are fundamental concepts in object-oriented programming (OOP), including Java. Let’s explore each of these concepts: Overview What is Inheritance? Accessibility Method Overriding Calling the Superclass’s Constructors Type Casting The instanceof Keyword What Is Inheritance? Concept of OOP, using which we organize classes in hierarchy. Used to avoid redundancy and … Read more

Arrays, Boxing & Unboxing

Note: Arrays, boxing, and unboxing are important concepts in Java related to handling data, especially primitive data types and their object counterparts. Let’s explore these concepts Arrays Java object used to group primitives or objects. All components have the same type, e.g. int, String etc. Size cannot be changed after creation. Some methods:- public static … Read more

String Classes, Buffer And Builder

In Java, the String class, String-Buffer, and String-Builder are classes used to work with text data, but they have different characteristics and are suited for different scenarios. System java.lang.System is a final class exposing utility functions Some fields & methods:- public static final java.io.PrintStream out; public static final java.io.PrintStream err; public static final java.io.InputStream in; … Read more