java core

Your blog category

Inheritance Introduction

Inheritance is a fundamental concept in object-oriented programming (OOP) that allows a new class, called the “subclass” or “derived class,” to inherit attributes and behaviors from an existing class, known as the “superclass” or “base class.” The derived class can reuse, extend, or override the functionalities of the base class. Key points about inheritance Code […]

Inheritance Introduction Read More »

Composition,Inheritance and Deligation

In Java, Composition, Inheritance, and Delegation are three fundamental concepts used in object-oriented programming, each serving distinct purposes in structuring classes and their relationships. Composition Composition involves creating complex objects by combining simpler ones, forming a “has-a” relationship. In Java, this is achieved by including an instance of another class within a class. For example,

Composition,Inheritance and Deligation Read More »

Access Specifiers

Access specifiers in Java are keywords that define the visibility or accessibility of classes, methods, and fields within a Java program. There are four access specifiers in Java: public, private, protected, and default (package-private). Public The public access specifier allows unrestricted access to the associated class, method, or field. It can be accessed from any

Access Specifiers Read More »

Programs on Polymorphism

1. Constructor Overloading practice program-1 This program demonstrates constructor overloading by creating objects with different constructors. It initializes student details using both the default and parameterized constructors. 2. Constructor Overloading practice program-2 This program calculates the area of a square and a rectangle using overloaded constructors. Different constructors initialize the required dimensions. 3. Method Overloading

Programs on Polymorphism Read More »

Method Overloading

Method overloading in Java is a powerful feature that allows a class to have multiple methods with the same name but different parameters within the same class. This provides flexibility and enhances code readability. The main advantages of method overloading in Java are as follows Readability and Simplicity:Method overloading makes code more readable and simpler

Method Overloading Read More »

Constructor Overloading

In Java, constructor overloading refers to the practice of defining multiple constructors within a class, each with a different parameter list. This allows an object to be instantiated in various ways, providing flexibility and versatility in how instances of a class are created. Constructor overloading is a form of polymorphism in which a class has

Constructor Overloading Read More »

Introduction

Object-Oriented Programming (OOP) is a fundamental paradigm in the world of software development. It’s a programming approach that revolves around the concept of “objects” and provides a structured way to model real-world entities, their behaviours, and their interactions within a computer program. This introduction will delve into the core principles and concepts of OOP, providing

Introduction Read More »

this keyword

In Java, the this keyword is a reference variable that is used to refer to the current object within a method or constructor. It is particularly useful in situations where instance variables and parameters have the same names, helping to distinguish between the two and avoid naming conflicts. Key Uses of the this Keyword Distinguishing

this keyword Read More »

Scroll to Top