Master List Of Core Java Questions
What is an Object?
An object is an entity with certain attributes or qualities and behaviors, for a simple example, a 'Laptop' is an object which has certain attributes like weight,color,screen size,manufacturer etc.It has various behaviors or activities to do or act upon, as play games, browse Internet,write/check emails , watch movies ,listen music etc.
What is a Class?
A class is a collection of attributes and behaviors of objects with certain similarities and an instance of a class is represented by an object.A simple example of class is a 'Car' which represents variety of Car objects with different attribute values and behaviors.The different objects of 'Car' class can be, for example : A Mercedes Car,a Toyota Car, two different objects from same class but different attributes and different behaviors too.
What is OOAD?
Object Oriented Analysis and Design(OOAD) is a methodology to analyze,design and develop application using objects and their relations and message based communication to each other.Everything in OOAD is visualized in terms of objects and classes.OOAD introduced a paradigm shift from thinking and programming procedurally to objects oriented programming.This approach helps in designing complex real time systems with ease.The features like Data Abstraction and Encapsulation, Inheritance and Polymorphism form fundamentals of object oriented programming.
• Enhanced Reusability
• Modular approach towards problem solving which will be
• Better Maintainability
Better Performance if system is designed cautiously using OOAD concepts
What is Data Abstraction?
Data Abstraction is extraction of essential information for a particular purpose and ingnoring the remainder of the information,e.g. a car is consisted of an engine,air filters,a carburetor,a gear box,a steering,a fuel tank,tyres etc.A driver of a car need not to be bothered about several finer points of the car,he/she should know what it requires to drive a car.Take another user, a car mechanic, he will require different set of information in order to repair the car.
What is Data Encapsulation?
Data Encapsulation is wrapping informations(attributes and behaviors) within an object.A suitable example is a class as it wraps methods and data within itself. The attributes of a class corresponds to its data members while behaviour corresponds to member methods of the class.
What is the difference between Data Abstraction and Information Hiding?
Data Abstraction is often confused with information hiding while they altogether are two different technical concepts.Here are few established definitions of Data Abstraction:
What is Inheritance and what are different types of it?
Inheritance is a mechanism by which a specific object acquires attributes and behaviors of more general objects.In OOP terminology ,Inheritance is the mechanism which allows a Class 'A' to inherit properties of Class 'B' and we say 'A inherits from B' or in other words B is a 'Superclass'/'Parent class' while A is a 'Subclass'/'Child class'. A typical example of inheritance is a family tree which consists of son,father,grandfather,great grandfather and so on.The different types of Inheritance are:
Why Java uses Singly rooted hierarchy?
All objects in Java are inherited from same base class called 'Object'.In Java all objects have common interface to implement and it makes implementaion of Garbage collector lot easier in Java.The necessary implementaion is provided in base class , and the garbage collector can then send the necessary messages to every objectc in the system.Without singly rooted hierarchy,it would have been difficult to implement garbage collection feature.It enables lot of ease to programmers not to be bothered about memory management while development.It greatly simplifies argument passing amongst object too on the heap. As Java started from scratch and has no backward compatibility issues with any existing language, it was a logical choice to use the singly-rooted hierarchy in common with most other object-oriented programming languages.