bing
Flat 10% & upto 50% off + Free additional Courses. Hurry up!

Abstract Class and Interface

 

Abstract Class

Class declared with Abstract keyword is known as abstract class in java.  This abstract class have abstract and non-abstract methods. Basically abstract is a process of hiding the properties and showing only functionality to the user. It shows only important things to the user and hides the internal details.

abstract class ClassOne

{

abstract public void method();

public void method1()

{

System.out.println("Method");

}

}

class ClassTwo extends ClassOne

{

public void method()

{

System.out.println("Method 2");

}

}

 

Interfaces

It is not a class, all methods declared in this block are incomplete. Interface block should be declared with ‘interface’ keyword.  Interface is a blueprint of class. Java core part and a way to achieve data  abstraction in java along with abstract class.  Multiple interface implementation allows to implemented subclass. It is fully abstract class. Here no need to declare abstract keyword and no need to declare interface keyword for all methods.  Let see the example.

interface Program1

{

public void method1();

}

class MyProgram1 implements Program1

{

public void method1()

{

System.out.println("hello this is overrided method..");

}

}


Difference between Abstract class and Interface

Abstract class Interface
It can have abstract and non abstract methods. It can have only abstract methods.
abstract keyword is used to declare abstract class interface keyword is used to declare interface.
It can contain static methods, main method and constructor. It cannot contain static methods, main method or constructor.
It does not support multiple inheritance. It supports multiple inheritance.
It can have final, non-final, static and non-static variables. It has only static and final variables.
It can provide the implementation of interface. It cannot provide the implementation of abstract class.

"0 Responses on Abstract Class and Interface"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.

top

Sales Offer

  • To avail this offer, enroll before 10th December 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer
offer-june

Sign Up or Login to view the Free Abstract Class and Interface.