Core Java - Interview Questions VI


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

Comments