Monday, 13 February 2012

What is a Marker Interface?

An Interface which doesn't have any declaration inside but still enforces a mechanism.

Can an Interface be defined inside a class?

Yes it's possible.

Can a class be defined inside an Interface?

Yes it's possible.

Java Introduction?


Java is a programming language. It was developed by James Gosling at Sun Microsystems, which is now a supportercompany of Oracle Corporation. It was released in 1995. It is a core component of Sun Microsystems' Java platform. Java language derives most of its syntax and semantics from C and C++ but Java has a simpler object model and fewer low-level facilities. Java applications are compiled to bytecode that is class file which run on any Java Virtual Machine (JVM) irrespective of computer architecture.

Sunday, 12 February 2012

Can an Interface be final?

Not possible. Doing so so will result in compilation error.

Why is an Interface be able to extend more than one Interface but a Class can't extend more than one Class?

Basically Java doesn't allow multiple inheritance, so a Class is restricted to extend only one Class. But an Interface is a pure abstraction model and doesn't have inheritance hierarchy like classes(do remember that the base class of all classes is Object). So an Interface is allowed to extend more than one Interface.

Can a Class extend more than one Class?

Not possible. A Class can extend only one class but can implement any number of Interfaces.