Submitted by heartin on Mon, 09/14/2015 - 21:34
Inheritance describes the parent child relationship between two classes.
A class can get some of its characteristics from a parent class and then add more unique features of its own. For example, consider a Vehicle parent class and a child class Car. Vehicle class will have properties and functionalities common for all vehicles. Car will inherit those common properties from the Vehicle class and then add properties which are specific to a car.
Submitted by heartin on Mon, 09/14/2015 - 21:27
The ability to change form is known as polymorphism. Java supports different kinds of polymorphism like oveloading and overriding.
Overloading
The same method name (method overloading) or operator symbol (operator overloading) can be used in different contexts.
In method overloading, multiple methods having same name can appear in a class, but with different signature. And based on the number and type of arguments we provide while calling the method, the correct method will be called.
Submitted by heartin on Mon, 09/14/2015 - 20:49
In plain English, abstract means a concept or idea not associated with any specific instance and does not have a concrete existence. Abstraction in Object Oriented Programming refers to the ability to make a class abstract. Abstraction captures only those details about an object that are relevant to the current perspective, so that the programmer can focus on a few concepts at a time.
Java provides interfaces and abstract classes for describing abstract types.
Submitted by heartin on Mon, 09/14/2015 - 13:02
The instanceof operator compares an object to a given type and checks if the type of object in left side is assignment-compatible to the type in the right side. i.e., if we can say right-side-type = left-side-type object without any casting.
Submitted by heartin on Sun, 09/13/2015 - 08:26
-
Only non-static visible instance methods can be overriden:
-
Private methods are not visible and hence not overriden.
-
Protected methods can be overriden by a subclass within the same package.
-
Static methods are not overriden, but they are inherited.
-
When you refer to a child class object using a Parent reference (e.g. Parent p = new Child()) and invoke a method, the overriden child class method will be invoked.
Pages