More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. Cloneable is a declaration that the class implementing it allows cloning or bitwise copy of it's object state. It is not having any method because it is a MARKER interface.
Help us improve. Please let us know the company, where you were asked this question :
Ans. It is used to sort collections and arrays of objects using the collections.sort() and java.utils. The objects of the class implementing the Comparable interface can be ordered.
Help us improve. Please let us know the company, where you were asked this question :
Ans. It is a collection of element which cannot contain duplicate elements. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism.
Help us improve. Please let us know the company, where you were asked this question :
Ans. An enumeration is an interface containing methods for accessing the underlying data structure from which the enumeration is obtained. It allows sequential access to all the elements stored in the collection.
Help us improve. Please let us know the company, where you were asked this question :
Q51. Can we have default method with same name and signature in the derived Interface as the static method in base Interface and vice versa ?
Ans. Yes , we can do that as static methods are not accessible using references and hence cannot lead to conflict. We cannot do inverse as Default methods cannot be overridden with the static methods in derived interface.
Help us improve. Please let us know the company, where you were asked this question :
Ans. This is an informative annotation that specify that the interface is a functional interface. A Function Interface has only one abstract method and many default methods. Compiler generates an error if the interface specified with the annotation doesn't abide by the specifications for functional interface.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Abstract classes can have both abstract methods ( method declarations ) as well as concrete methods ( inherited to the derived classes ) whereas Interfaces can only have abstract methods ( method declarations ).
A class can extend single abstract class whereas it can implement multiple interfaces.
Help us improve. Please let us know the company, where you were asked this question :
Ans. It's a choice to be made whether to use first approach ( Thread class ) or second approach ( runnable interface ) by the programmer. The second facility has been given for cases where your class is already extending some parent class and hence cannot extend another class ( for Thread ) as Java doesn't allow multiple inheritance.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Thread class holds the definition of start method ( This is the method that starts execution of new thread and then calls run method within the scope of new thread ). Interfaces don't hold any definition and so does runnable. So it makes it necessary the usage of Thread class , whatever implementation you choose.
When your class extends the thread class, it carries the definition of start method from parent Thread class onto itself and hence new yourClass.start() helps starting a new thread and then executing run method in that new thread scope.
When you implement runnable interface , you are just making it sure to the JVM that you have implemented the required method ( run() ) which the Thread start method will look for upon executing start method.
Help us improve. Please let us know the company, where you were asked this question :
a. Member elements and Methods. b. Static Variables and Static Methods. c. Static Final Variables and Instance Method Declarations. d. Member Elements , Instance Methods, Static variables and Static Methods.
Ans. Static Final Variables and Instance Method Declarations.
Help us improve. Please let us know the company, where you were asked this question :