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