As a programmer it is very much essential to know the uses of final keyword in Java. final keyword can be used along with variables, methods and classes. In this article we will be looking into the following topics. 1) final variable 2) final method 3) final class … [Read more...]
Types of Inheritance in Java – Single,Multiple,Multilevel,Hierarchical & Hybrid
Below are the different types of inheritance which is supported by Java. Single Inheritance Multiple Inheritance (Through Interface) Multilevel Inheritance Hierarchical Inheritance Hybrid Inheritance (Through Interface) … [Read more...]
Hybrid Inheritance in Java with Example
Hybrid Inheritance is a combination of both Single Inheritance and Multiple Inheritance. Since in Java Multiple Inheritance is not supported directly we can achieve Hybrid inheritance also through Interfaces only. … [Read more...]
Hierarchical Inheritance in Java with Example
In this inheritance multiple classes inherits from a single class i.e there is one super class and multiple sub classes. As we can see from the below diagram when a same class is having more than one sub class (or) more than one sub class has the same parent is called as Hierarchical Inheritance. … [Read more...]
Multilevel Inheritance in Java with Example
In Java Multilevel Inheritance sub class will be inheriting a parent class and as well as the sub class act as the parent class to other class. Lets now look into the below flow diagram, we can see ClassB inherits the property of ClassA and again ClassB act as a parent for ClassC. In Short ClassA parent for ClassB and ClassB parent for ClassC. … [Read more...]
Multiple Inheritance in Java Example
Multiple Inheritance in Java is nothing but one class extending more than one class. Java does not have this capability. As the designers considered that multiple inheritance will to be too complex to manage, but indirectly you can achieve Multiple Inheritance in Java using Interfaces. … [Read more...]
Single Inheritance in Java with Example
Inheritance is one of the key features of object-oriented programming (OOP).Single Inheritance enables a derived class(Sub class) to inherit properties and behavior from a single parent class(Super class). … [Read more...]
Inheritance in Java with Example Programs
Inheritance is one of the important concept in OOPs. Java Inheritance is a process by which one class can re-use the methods and fields of other class. The Derived class(Sub class - The class which inherits the Parent class) re-uses the methods and variables of the Base class(Super class). … [Read more...]
Can we Override static methods in Java
No, We cannot Override a static method in Java. Unlike Overloading of static method we cannot do overriding. When we declare a method with same signature and static in both Parent and Child class then it is not considered as Method Overriding as there will not be any Run-time Polymorphism happening. … [Read more...]
Can we Overload static methods in Java
Yes, you can overload a static method in Java. Java Method Overloading is one of the feature in OOPs concept which allows you to have two or more methods with same method name with difference in the parameters in other words, we can also call this phenomena as Compile time polymorphism. … [Read more...]
Types of polymorphism in java – Runtime Polymorphism, Compile time Polymorphism
As we all know what is polymorphism in java, now its time to dig a bit deeper into it. There are two types of Polymorphism which is possible in Java, Runtime Polymorphism (Dynamic Binding) and Compile time Polymorphism (Static Binding). Lets take a look into it one by one. … [Read more...]
Encapsulation in Java with Example
Encapsulation in Java is the process of wrapping code and data together into a single unit. Encapsulation hides the implementation details from the users. If the data member is private then it can be accessed only within the same class . No other outside class can access the private member of other class. … [Read more...]