Category Archives: Java OOPS

Enum in Java

In this tutorial, we will learn about Enum in Java. In Java Enum is a kind of class and it is used to represent a group of constants. For example days of week and months of the year etc. Enum is only used in case we know all the possible values(constants) on the time of compiling code. There… Read More »

Difference between Abstract class and Interface

In the last tutorials two tutorials, we learned about abstract class and interface. In this tutorial, we will learn what is the difference between Abstract class and Interface. Abstract class Interface An abstract class can have both abstract and non-abstract methods. But an Interface can have only abstract methods. We can not perform multiple inheritances in the abstract class. But in the… Read More »

Interface in Java

In this tutorial, we will learn about Interface in Java. Interface is like an blue print of class. An Interface contain all its variable as static, final and all its methods as abstract. You can say an Interface is a complete Abstract class. We can not instantiate interface same as abstract class we can only use an interface… Read More »

Abstract class in Java

In this tutorial, we will learn about the Abstract class in Java. The main motive of creating an abstract class is to restrict the user to create an object of the class. Abstract classes can only be used with the help of inheritance means we can inherit the abstract class in class. Java provides us “abstract” which we… Read More »

Static block in Java

In this tutorial, we will learn about Static block in Java. A very important thing about the static block is the static block belongs to class not to instance. That’s why static block only runs once it doesn’t matter how many numbers of instance we create. There are few things to note about the static block in Java.… Read More »

Instance block in Java

In this tutorial, we will learn about Instance block in Java. Instance blocks are used to initialize instance variables of the class. These blocks run every time when we create an object of the class. There are few things to note about instance blocks. we do not right any identifier with instance block instance block run every time… Read More »

Final Keyword in Java

In this tutorial, we will learn about the final keyword in Java. The main motive of the final keyword is to restrict the user and final keyword can be used to create three kinds of restriction. These are: final with variable final with method final with class Final keyword in Java with variable: The final keyword is to… Read More »

Super keyword in Java

In this tutorial we will learn about super keyword in Java. super keyword in java refers to object of Parent class. Super keyword is mainly use to call super class methods or constructor of super class. Usage of super keyword: The super keyword can be used to use the variable of parent class in child class. The super… Read More »

Method Overriding in Java

In this tutorial, we will learn about Method Overriding in java. If we create a method in the child class with the same name as declared in parent class it is known as Method Overloading. Rules to perform Method Overloading in Java: Method name should be same as declared in Parent class. Parameter of the method should be… Read More »

Constructor Overloading in Java

In this tutorial, we will learn about Constructor Overloading in Java. A constructor can be over overload just like Method Overloading. In java, we can create more than one Constructor in class. The only rule is all the constructors should have different arguments(In the number of arguments or type of arguments). Rules to perform Constructor Overloading in Java:… Read More »