Posts

Showing posts with the label polymorphism

Polymarphism interview questions and answers in java

Polymorphism is one of the Oops concept and mostly used feature in java. The ability of an object to take more than one form is called Polymorphism. The most common use of polymorphism in OOPs occurs when a parent class reference is used to refer to a child class object.         It is impossible to know that the only possible way to access the object is through a reference variable. A reference variable can be of  only one type. Once declared, the type of the reference variable cannot be changed.         A reference variable can refer to any object of its declared type or any subtype of its declared type. A reference variable can be declared as a class or interface. Ex: Let's take a look into the below example 1 2 3 4 5 interface Vehicle {} class Mileage {} public class Car extends Mileage implements Vehicle {} see the implementation of the above example, 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ...

Object Oriented Programming in java

Object Oriented Program or Oops is a technique to create programs based on the real world object. In the Oops programming model programs are organized around objects and data rather than actions and logic. What is Oops?           An Object Oriented Programming organizes a program around its data, i.e., objects and a set of well defined interfaces to that data. An object-oriented programming can be characterized as data controlling access to code. Why Oops?           Object Oriented Programming enables programmers define not only the data, but also its associated behaviors that can be applied to the data. It also enables programmers to create relationship between one object and another. For example, Objects can inherit characteristics from other objects. To understand the importance of Oops first we need to understand the problem with Procedural...