Core Java Interview Question Page 3

Question: When you declare a method as abstract method ? Answer: When i want child class to implement the behavior of the method.

Core Java Interview Question Page 3

Core Java Interview Question Page 3

     

Question: When you declare a method as abstract method ?

Answer: When i want child class to implement the behavior of the method.

Question: Can I call a abstract method from a non abstract method ? 

Answer: Yes, We can call a abstract method from a Non abstract method in a Java abstract class         

Question: What is the difference between an Abstract class and Interface in Java ? or can you explain when you use Abstract classes ? 

Answer: Abstract classes let you define some behaviors; they force your subclasses to provide others. These abstract classes will provide the basic funcationality of your applicatoin, child class which inherited this class will provide the funtionality of the abstract methods in abstract class. When base class calls this method, Java calls the method defined by the child class.

  • An Interface can only declare constants and instance methods, but cannot implement default behavior.
  • Interfaces provide a form of multiple inheritance. A class can extend only one other class.
  • Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc.
  • A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class.
  • Interfaces are slow as it requires extra indirection to find corresponding method in the actual class. Abstract classes are fast.

Question: What is user-defined exception in java ? 

Answer: User-defined expections are the exceptions defined by the application developer which are errors related to specific application. Application Developer can define the user defined exception by inherite the Exception class as shown below. Using this class we can throw new exceptions. Java Example : public class noFundException extends Exception { } Throw an exception using a throw statement: public class Fund { ... public Object getFunds() throws noFundException { if (Empty()) throw new noFundException(); ... } } User-defined exceptions should usually be checked.

Tutorials

  1. Core Java Interview Question Page 1
  2. Core Java Interview Question Page 3
  3. Core Java Interview Question Page 8
  4. Core Java Interview Question, Interview Question
  5. Core Java Interview Question, Interview Question
  6. Core Java Interview Question, Interview Question
  7. Core Java Interview Question, Interview Question
  8. Core Java Interview Question, Interview Question
  9. Core Java Interview Question, Interview Question
  10. Core Java Interview questions and answers
  11. Core Java Interview Question, Interview Question
  12. Core Java Interview Question, Interview Question
  13. Core Java Interview Question, Interview Question
  14. Core Java Interview Question, Interview Question
  15. Core Java Interview Question, Interview Question
  16. Core Java Interview Question, Interview Question
  17. Core Java Interview Question, Interview Question
  18. Core Java Interview Question, Interview Question
  19. Core Java Interview Question, Interview Question
  20. Core Java Interview Question, Interview Question
  21. Core Java Interview Question, Interview Question
  22. Core Java Interview Question, Interview Question
  23. Core Java Interview Question, Interview Question
  24. Core Java Interview Question, Interview Question
  25. Core Java Interview Question, Interview Question
  26. Core Java Interview Question, Interview Question
  27. Core Java Interview Question, Interview Question
  28. Core Java Interview Question, Interview Question
  29. Core Java Interview Question, Interview Question
  30. Core Java Interview Question, Interview Question
  31. Core Java Interview Question, Interview Question
  32. Core Java Interview Question, Interview Question
  33. Core Java Interview Question, Interview Question
  34. Core Java Interview Question, Interview Question
  35. Core java Interview Questions