Saturday, November 7, 2015

Getting Ready for Technical Interviews - 3

Java Constructors

It is like a method that used to initialize the instance variables of an object invoked at the time of object creation. 

  • Every constructor has either this() call or super() call as its first statement. If we don't define custom constructor then it implicitly put super() for default constructor.
  • Never be inherited and never be overridden.
  • But it can be overloaded. 
  • Normally public, default,private and protected access modifiers can be used. 
  • Constructors name same as class name. But no return type.
  • Default constructor always no argument constructor and it has same access modifier as class.

Basic Java concepts

  • Inheritance
  • Polymorphism
  • Abstraction
  • Encapsulation

Define Inheritance ?

It is the process of where one object acquires properties and behaviors of another object of another class. It represents IS_A relationship and used for code re usability and method overloading.

What is  Polymorphism ?

It short meaning is, same thing in different form. It is ability of an object to take on many forms. 

Abstraction

It means ignoring irreverent features, properties or functions and emphasizing the relevant ones. It helps to deal with creating, understanding and managing complex systems. 

Encapsulation

Enclosing proper attributes and methods inside a single class. Benefits of encapsulation are given below.
  • Ability to modify our implemented code without breaking the code of others who use our code.
  • Maintainability
  • Flexibility
  • Extensible ability of our code 

Previous    

No comments:

Post a Comment