Correct Answer: The diamond problem is an ambiguity that can occur when a class multiply inherits from two classes that both descend from a common super class
4. What is the difference between array and ArrayList ?
Correct Answer: Array is collection of same data type Array size is fixed, It cannot be expanded But ArrayList is a growable collection of objectsArrayList is a part of Collections Framework and can work with only objects
Correct Answer: Yes, we can In order to compile a java program, we don't require any main method But to execute a java program we must have a main in it (unless it is an applet or servlet) Because main is the starting point of a java program
7. What are the restrictions when overriding a method ?
Correct Answer: Overridden methods must have the same name, argument list, and return type (ie, they must have the exact signature of the method we are going to override, including return type) The overriding method cannot be less visible than the method it overrides( ie, a public method cannot be override to private) The overriding method may not throw any exceptions that may not be thrown by the overridden method
Correct Answer: Path and Classpath are operating system level environment variales Path is used define where the system can find the executables(exe) files and classpath is used to specify the location class files
9. What is the impact of declaring a method as final?
Correct Answer: A static initializer block is a block of code that declares with the static keyword It normally contains the block of code that must execute at the time of class loading The static initializer block will execute only once at the time of loading the class only