Java Oops Concepts


Inheritance : use parent class veriable and method using child class object

  1. Create object of child class and reference of child class, using this object access all methods of base class and child class

2. Create object of base class and reference of base class, allow to access all method of base class only

3. Create reference of base class but object of child class, allow to access method of base class only not child class method

Inheritance –

Interface implement in selenium –


2 Type of Polymorphism

  1. Compile time called early binding

Overloading : Same method name but different signature(No of arguments, Type of arg,order of arg)

e.x. add(int a, int b) and add(int a, int b, int c)

2. Runtime called Late biding



Showing the functionality by hiding the implemetation details.

Abstact class must have atleast one abstract method

Abstract class have both concreate and abstract method

In Abstract class you can define member variables

common functionality define in the abstract class and functionalty change in subclass define in asbstract method

when extend abstract class then going to implement in sub class to achive the code resuability


abstract class Bank 
   public void diposite() {
         system.out.println("common deposite method across all banks");
    public void withdraw() {
        system.out.println("common withdraw method across all bank");

public abstract int calculteInterest();

every bank have different formula to calculating the interest so extands bank class will implement the calculateInterest method()

class HDFC extends Bank{
  public int calcualteInterst(){
      System.out.println("HDFC bank Calculate Interest Implentation");
Bank hdfc = new HDFC();


In Interface all methods are bydefault abstract

public interface BankInterface {
   public abstract  void diposite();
   public abstract void withdraw();
   public abstract void calculateInterest();

bydefault declare method is public even define or not.

Class impements the interface must have to define the method

class HDFC implements BankInterface{
  public void depostie(){
     System.out.println("HDFCBank deposite Implementation");
  public void withdraw() {
      System.out.println("HDFCBank withdraw implentation");
  public void calculateInterest(){
      System.out.println("HDFCBank calculate interest implementation");
Bankinterface hdfcbank = new HDFCBank();

By using the interface achive multiple inheritance


About samp79

Professional Automation Tester
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s