Java language is developed using object oriented programming (OOP) concept as its platform. This object oriented programming language concept organizes data into different classes, providing the data proper hierarchy through inheritance mode. There are four basic principles defined under the OOP concept in Java which is very popular among interviewers during technical recruitment for Java developer posts. These four basic concepts consist of major portions of Java interview questions in technical interviews as the recruiter is interested in knowing whether the candidate is familiar with the basic concepts of OOP language or not. So do read all the 4 basic OOP concepts described here to crack Java interview questions.
1. Abstraction Principle: This principle gives unique characteristics to all the objects present in a class so as to group similar objects in one class as well as defining the boundary of each class on the basis of objects distinct characteristics. The abstraction feature is used by classes to give distinct attributes to data such as weight, cost, size and methods or functions to work on these particular attributes. In the abstraction principle, a user can only utilize the methods provided because these methods work on some particular interface to complete the task properly and in a particular order.
2. Encapsulation Principle: This principle combines the member data as well as the member function into a single unit so that the basic property of data gets hidden, providing security to user data. The encapsulation principal prohibits the access of data by a third party or outside member which further secures the data. The basic difference between the abstraction & encapsulation principles is that the former gives access to a third party for data viewing while latter does not have this facility due to security reasons.
3. Inheritance Principle: This principle provides the mechanism of sharing attributes of classes and various operations present along with them. Thus by using inheritance principle an object of one class can acquire the property of another class falling under the same hierarchy. While categorizing the classes using the inheritance principle, the old class is referred as the parent class, base class or super class, while the newly formed class is referred to as the child class, subclass or derived class.
4. Polymorphism Principle: This principle becomes handy if a user wants to use a single operation under different names for a similar kind of operation. For example, if you want to draw a triangle, a square and a rectangle then you can use the draw operation on these three objects by substituting the object name with the draw operation on all the three different objects thus saving both the data space as well as simplifying the program execution. This feature of Polymorphism helps in function as well as operation overloading while dealing with bulky and large data.
In order to read more on the OOP concept for mastering Java interview questions, you can look to various online resources such as Java interview questions online tutorial guide, eBooks on Java OOP concept. Also do practice the program execution based on these concepts because theoretical knowledge combined with programs would help you in scoring high marks in Java technical interview.
No comments:
Post a Comment