Java Abstract Class

Abstract class in the real world Let us take an example of graphic objects. Different graphic objects are there such as circles, rectangles, triangles, etc. They all have states defined by their positions, color, etc., and behavior defined by drawing, resizing, calculating size, etc. All these object types have common things but with different implementations. … Read more

Java Command Line Arguments

Command line arguments are the arguments that are passed at run time to the Java program. Arguments are used as input for the program. There is no limit on the number of command line arguments that can be passed to the program. Command line arguments are string by default because they are received by the … Read more

Java Inheritance

Inheritance refers to a way of implementing an IS-A relationship i.e. parent-child relationship. A subclass inherits the superclass properties like data members and methods. Inheritance is a way of code re-usability. Let us consider an example of parent and child. A child inherits the properties of its parent. Use of Inheritance Code re-usability. Run-time polymorphism. … Read more

Java Association Aggregation And Composition

Association is a mechanism to define a relationship between classes of objects. Two classes are said to be associated with each other if they are related to each other in some way. Types of Association Is-A Has-A Aggregation Composition Important definitions for association Subclass/child class/ derived class A class which is derived from another class. … Read more

Java Dynamic Method Dispatch | Runtime Polymorphism In Java

Dynamic method dispatch is a way to resolve overridden method calls at run time instead of compile time. It is based on the concept of up-casting. Up-casting means “A super class reference variable can refer to subclass object”. Java Dynamic Method Dispatch Example package com.w3schools; class Engineer { public void show(){ System.out.println(“Engineer details.”); } } … Read more

Java Method overriding

If a subclass provides a method with the same signature (name and parameter) as in its superclass, then the subclass overrides the method of its superclass. This process of overriding a superclass method by a subclass is known as method overriding. Conditions for method overriding: The method in a subclass must have the same signature … Read more

Method overloading in java

Method overloading is a mechanism to implement static/compile time polymorphism in Java. Method overloading means more than one method in a class with the same name but different parameters. Parameters can differ in type, number, or order. Compiler resolves method calls by matching the method signature at compile time, that’s why it is known as … Read more