Loading
Oops Interview Questions

Java Quick Notes

Refresh Your Java

We are Agile, believe in less Documentation - Only Quick notes of Java/J2ee Read more....


"Click on other Tabs for more Questions"  

"Oops "


This Section focuses on general OOPs concepts and some differences between OPPs and Structural Languages.

1 )   What is OOPs and its concept ?


Ans)

Object Oriented Programming or OOP is the technique to create programs based on the real world. Unlike procedural programming, here in the OOP programming model programs are organized around objects and data rather than actions and logic.

Objects represent some concepts or things and like any other objects in the real Objects in programming language have certain behavior, properties, type, and identity.

There are four main features of OOPS.
1) Encapsulation
2) Inheritance
3) Polymorphism
4) Abstraction


Encapsulation
Encapsulation means putting together all the variables (Objects) and the methods into a single unit called Class.

Inheritance
Inheritance is mainly used for code reusability. You already have defined an Object or rather you have already defined set of attributes and characteristics which you like to make you it again and expand up on it.

Polymorphism
Polymorphism advices to use common interface instead of concrete implementation while writing code. When we program for interface our code is capable of handling any new requirement or enhancement arise in near future due to new implementation of our common interface.

Abstraction :
Abstraction means Data hiding and control the accessibility , means to show only the necessary details to the client of the object.



Back to top

2 )   What is the Difference between OOP and Structural Programning ?


Ans)

Structural Programming  is programming language which contains a set of Functions or Produces and follow a flow to execute these and fulfill some tasks, it does not have any concept called Object and does not fully support very important aspects of the programming language like "Data Hiding Or Abstraction", "Polymorphism", and "Inherence."

Unlike Structural Programming in OOPs everything is a Object, it supports the things like "Data Hiding Or Abstraction", "Polymorphism", and "Inherence." full-fledgedly .



Back to top

3 )   What is an Interface ?


Ans)

An interface is a named collection of method definitions (without implementations). An interface can also include constant declarations.

public interface First Interface {
   public void println(String str) ;
}



Back to top

4 )   What is an Class ?


Ans)

Java class is nothing but a template for object you are going to create or it’s a blue print by using this we create an object.

public class FirstInterface {
   public void println(String str) {
   System.out.println(str);  
   }
}



Back to top

5 )   What is an Multiple Inheritance ?


Ans)

Multiple inheritance is a feature of some object-oriented computer programming languages in which a class can inherit behaviors and features from more than one superclass.



Back to top

6 )   What is Runtime polymorphism ?


Ans)

"Runtime time polymorphism" is done using inheritance and virtual functions, this is also called "Function Overriding". For example we could override the functionality of any method of Super Class by having different implementation is subclass. See the example below "Shape.draw()" is overridden in "Reactangle.draw()" class. So please note with out "inheritance" overriding would not be possible.  

public Class Shape {
   public void draw () {
   }
 }
 public Class Rectangle extends Shape {
   public void draw () {
      //Different Implementation here.  
  }
 }



Back to top

7 )   What is Compile Time polymorphism ?


Ans)

Compile time polymorphism is nothing overloading the functions and operators of the same class, "inheritance" is not required this case, this is also called as function overloading.

So in a class two or more functions can have same name but their parameter list should be different either in terms of parameters or their data types. The functions which differ only in their return types cannot be overloaded.



Back to top

8 )   What is the Difference Between an Interface and an Abstract Class ?


Ans)

An Abstract class without any implementation just looks like an Interface; however there are lot of differences than similarities between an Abstract class and an Interface. An abstract class could have have implemented and unimplemented methods where as Interfaces could only have method declarations(no implementation) .

Please note an abstract class is a special kind of class that cannot be instantiated.



Back to top

9 )   How could we implement Multiple Inheritance in Java?


Ans)

Java says Multiple inheritance can be done using Interfaces, unlike C++ Java would not allow to create a Class which extends two Super Classes instead it allows to create a Class which Implement two Interfaces.



Back to top

10 )   Difference between java and C++?


Ans)

Though both java and C++ are Object Oriented programming languages, there are several differences between them,  some of important differences are listed below.

  • In C++ you have to take the responsibly of memory management meaning you have to delete(destroy) the Objects explicitly is once you are done with using them otherwise memory will not be released, where as in Java this is managed by Garbage collector, this destroys the unused Objects and releases the memory .
  • Java is platform independent due to the byte code it generates upon compilation , C++ is not .



Back to top

11 )   Different Access Modifiers ?


Ans)

Visible to the package. the default. No modifiers are needed.
Visible to the class only (private).
Visible to the world (public).
Visible to the package and all subclasses (protected).



Back to top

Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

This Portal is intended to put all Java/J2ee related topics at one single place for quick referance, not only Technical , but also the Project Management Related thing such as Development Process methodoogies build process, unit testing etc.,

This Portal has More than 500 Java Interview Questions (also could be Considered as Quick Notes) very neatly separated topic by topic with simple diagrams which makes you easily understandable. Importantly these are from our Realtime expericance.




Face Book

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free

Go To Site Map