Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

100 Core Java Interview Questions and Answers - Part 3

Here are top selected core Java interview questions asked in high level interviews, these questions may be helpful for both freshers or experienced professional going for interview.




21) What are instance variable in Java?

In java, variables which are declared at class level outside methods body are called instance variables. Instance variables need not to initialize before using them, instance variables are automatically initialized to their default value. Each instance of a class have their own copy of instance variables.

22) What is return type of main method in Java?

In java, main method does not return anything hence return type of main method is ‘void’.

23) Why do we declare main method as static in Java?

In Java, main method is called by JVM itself end even before the instantiation of the class, hence main method in declared as static.

24) What arguments do a main method accepts in Java?

In Java, main() method accepts an array of String objects as parameter.

25) Which package is imported by default in Java ?

java.lang packages is imported by default in all java programs.

26) What if a variable is declared as final in Java?

If a primitive type variable is declared as final than its value cannot be changed once initialized. If a referenced type variable is declared as final than it can not refer to any other object.

27) What if a method is declared as protected in Java ?

If a method is declared as protected, than it can be accessed in the classes of same package only or in the subclasses of the class in other packages.

28) Can we declare a class as protected in Java?

No, we cannot declare a class or interface as protected. However we can declare methods or variables or a class as protected, methods or variables inside an interface cannot be declared as protected.











Thanks for reading !
Being Java Guys Team




This post first appeared on Java, Struts 2, Spring, Hibernate, Solr, Mahout An, please read the originial post: here

Share the post

100 Core Java Interview Questions and Answers - Part 3

×

Subscribe to Java, Struts 2, Spring, Hibernate, Solr, Mahout An

Get updates delivered right to your inbox!

Thank you for your subscription

×