Java Language Interview Question and Answers

26. What is an instanceof operator?
  Instanceof is an object reference operator and returns true if the object on the left-hand side is an instance of the glass given to the right hand side.This operator allows to determine whether the object belongs to a particular class or not.
27. What are runtime exceptions?
  Runtime exceptions are those exceptions that are thrown at runtime because of either wrong input data or because of wrong business logic etc. These are not checked by the compiler at compile time.
28 What is the difference between an interface and an abstract class?
  An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class.
29. what is a package?
  A package is a namespace that organizes a set of related classes and interfaces.The classes contained in the packages of other programs can be easily reused.Packages, classes can be unique compared with classes in other packages.That is, two classes in two different packages can have the same name.
30. Why do threads block on I/O?
  Threads block on i/o (that is enters the waiting state) so that other threads may execute while the i/o Operation is performed.
123456789101112 Page 6 of 12