Question-51. Can an Interface be final ?
Answer- No, because its implementation is provided by another class.
Question-52. What is marker interface ?
Answer- An interface that have no data member and method is known as a marker interface. For example Serializable, Cloneable etc.
Question-53. Explain the following line used under Java Program: public static void main(String args[]) ?
Answer- The following shows the explanation individually −
• public − it is the access specifier. • static − it allows main() to be called without instantiating a particular instance of a class. • void − it affirms the compiler that no value is returned by main(). • main() − this method is called at the beginning of a Java program. • String args[ ] − args parameter is an instance array of class String
Question-54. What are wrapper classes ?
Answer- These are classes that allow primitive types to be accessed as objects. Example: Integer, Character, Double, Boolean etc.
Question-55. What is the difference between static and non-static variables ?
Answer- A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.
Question-56. What are use cases ?
Answer- It is part of the analysis of a program and describes a situation that a program might encounter and what behavior the program should exhibit in that circumstance.
Question-57. Can we define private and protected modifiers for variables in interfaces ?
Answer- No, they are implicitly public.
Question-58. When can an object reference be cast to an interface reference ?
Answer- An object reference can be cast to an interface reference when the object implements the referenced interface.
Question-59. What is package ?
Answer- A package is a group of similar type of classes interfaces and sub-packages. It provides access protection and removes naming collision.
Question-60. Do I need to import java.lang package any time? Why ?
Answer- No. It is by default loaded internally by the JVM.