Tuesday, 21 June 2016

Core java interview question and answers

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.
41. What is use of a abstract variable?
Variables can't be declared as abstract. only classes and methods can be declared as abstract.
42. Can you create an object of an abstract class?
Not possible. Abstract classes can't be instantiated.

No comments:

Post a Comment