Home Interview Questions and Answers Core Java Interview Questions and Answers For Freshers and Experience Part-7

core-java37. 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.

38. 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.

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. Can you create an object of an abstract class?

Not possible. Abstract classes can’t be instantiated.

42. What is use of a abstract variable?

Variables can’t be declared as abstract. only classes and methods can be declared as abstract.

You may also like

Leave a Comment