It2EDU

Thursday, February 16, 2017

Java Interview Questions


Java Interview Questions



1. Can we write a java program without main() method?

Ans: Yes we can write java program without main() method.

public class WithoutMain{

static{

System.out.println("without main method ");

System.exit(0);

}

}





2.What is the super class of every java class?


Ans: Object is the super class of every java class.





3.What is the difference between an Interface and an Abstract class?

Ans: An abstract class can have abstract and non-abstract methods but interface can have only abstract methods.

The abstract is the keyword is used to declare abstract class.

The interface is keyword used to declare interface.

Abstract classes does not support multiple inheritance. Interface supports multiple inheritance.

An abstract class can have static methods,constructor and main method. but interface cannot have these.

abstract classes can provide implementation for interfaces but interfaces cannot provide implementation of abstract classes.







0 comments:

Post a Comment