Here are top selected core java interview questions asked in high level interviews, these questions may be helpful for both freshers or experienced professional going for interview.
41) Can a class extend more than one class in Java?No, java does not support multiple inheritance. In java a class cannot extends more than one class but it can implement as many interfaces as it wants.
42) Can we declare a class inside an interface and vice verse?Yes, we can declare an interface inside a class and a class can be declared inside an interface, both statements are true.
43) What do you mean by a marker interface In Java?An marker interface is an interface which does not contain any variable or method in it, these interfaces are implemented by some classes to provide special instructions to JVM. The example is serializable interface this interface does not contain anything in it, it tell the JVM that the class which implements this interface needs to be serialized.
44) What modifiers are allowed inside an interface in Java?In java, interfaces can have public and abstract types of variables and methods in them. All the variables and methods are public abstract by default in an interface.
45) What is a constructor in java? Can constructors be overridden?Constructors are special type of methods that have the same name as the class itself and do not have a return type not even void. Constructors are used to create an object of a class, if we do not declare any constructor in our class than JVM provides a non argument constructor by default. Constructors cannot be overridden, though a subclass can call the constructor of its super class.
46) What access specifies are available in Java?In java there are four access specifies listed below their scope and usability.
1) public : public classes, methods and variables can be accessed from anywhere in the application, No restriction at all.
2) private: private variables and methods can be accessed in the same class only in which they are declared and not outside that, private variables and methods can not be accessed even in the subclasses.
3) protected: protected variables and methods can be accessed from anywhere in the same package and in the subclasses of same class outside the package.
4) default(no specifies): If a variable or method does not have any specifier than these can be accessed from anywhere within the same package and not outside the package.