Wednesday 11 February 2015

Core Java FAQs - Core Java Interview Questions and Answers (Page 8)

Below are some important Core Java interview questions which are asked in most MNC company interviews for beginners or professionals.

36. I want to print "Hello" even before main is executed. How will you achieve that?
Print the statement inside a static block of code. Static blocks get executed when the class gets loaded into the memory and even before the creation of an object. Hence it will be executed before the main method. And it will be executed only once.

37. What is the importance of static variable?
static variables are class level variables where all objects of the class refer to the same variable. If one object changes the value then the change gets reflected in all the objects.

38. Can we declare a static variable inside a method?
Static varaibles are class level variables and they can't be declared inside a method. If declared, the class will not compile.

39. What is an Abstract Class and what is it's purpose?
A Class which doesn't provide complete implementation is defined as an abstract class.
Abstract classes enforce abstraction.

40. Can a abstract class be declared final?
Not possible. An abstract class without being inherited is of no use and hence will result in compile time error.
More Questions & Answers :-
Page1  Page2  Page3  Page4  Page5  Page6  
Page7  Page8

No comments:

Post a Comment