Interview Questions on Interface in Java for Freshers

What is Interface ?

An interface is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface..


Main features of Interface ?

  • Interface cannot be instantiated
  • An interface does not contain any constructors
  • All of the methods in an interface are abstract


Can an Interface be final ?

No, because its implementation is provided by another class.


What is marker interface ?

An interface that have no data member and method is known as a marker interface.For example Serializable, Cloneable etc.


What is difference between abstract class and interface ?

An abstract class can have method body (non-abstract methods) but Interface have only abstract methods.


How to implement Interface in Java ?


Syntax

interface A
{
....
....
}
interface B
{
....
....
}
class C implements A,B
{
....
....
}

Related

Interview Questions 3046711875339850703

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item