Abstract and Interface

Java Marker Interface

Marker interface is used as a tag to inform a message to the java compiler so that it can add special behaviour to the class implementing it. Java marker interface has no members in it. Lets take the java.io.Serializable marker interface. It doesnot has any members defined it it. When a java class is to be [...]

Difference Between Interface and Abstract Class

Main difference is methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior. Variables declared in a Java interface is by default final. An  abstract class may contain non-final variables. Members of a Java interface are public by default. A Java abstract class can [...]

When can an object reference be cast to a Java interface reference?

When a Java object implements the referenced interface it can be cast to the Java interface reference.

Java interface

A java class containing all the methods as abstract is called an interface. A method that has no implementation and which is expected to be implemented by a subclass is called an abstract method. Java interface can contain constants. When an interface needs to be instantiated it should be implemented by a class and all [...]

How can you invoke a defined method of an abstract class?

An abstract class cannot be instantiated directly. An abstract class has to be sub-classed first and then instantiated. Only then the method defined in the abstract class can be invoked.

What is an abstract class?

A class containing atleast one abstract method is called an abstract class. A method that has no implementation and which is expected to be implemented by a subclass is called an abstract method. An Abstract class cannot be instantiated. It is expected to be extended by a subclass. An abstract class may contain static variables [...]

What is an abstract method?

A method that has no implementation and which is expected to be implemented by a subclass is called an abstract method.

Email:

about
I am Joe, author of this blog. I run this with loads of passion. If you are into java, you may find lot of interesting things around ...more about me. Google+
java badge
Home