core_java_faq_s-1

Share Embed Donate


Short Description

Download core_java_faq_s-1...

Description

CORE JAVA QUESTION: Can a private method of a superclass be declared within a subclass? ANSWER: Sure. A private field or method or inner class belongs to its declared class and hides from its subclasses. There is no way for private stuff to have a runtime overloading or overriding (polymorphism) features. QUESTION: Why Java does not support multiple inheritence? ANSWER: Java DOES support multiple inheritance via interface implementation. QUESTION: What is the difference between final, finally and finalize? ANSWER: o

final - declare constant

o

finally - handles exception

o

finalize - helps in garbage collection

QUESTION: Where and how can you use a private constructor? ANSWER: Private constructor can be used if you do not want any other class to instanstiate the object, the instantiation is done from a static public method, this method is used when dealing with the factory method pattern when the designer wants only one controller (fatory method) to create the object. QUESTION: In System.out.println(), what is System, out and println, pls explain? ANSWER: System is a predefined final class, out is a PrintStream object and println is a built-in overloaded method in the out object.

QUESTION: What is meant by "Abstract Interface"? ANSWER: First, an interface is abstract. That means you cannot have any implementation in an interface. All the methods declared in an interface are abstract methods or signatures of the methods. QUESTION: Can you make an instance of an abstract class? For example java.util.Calender is an abstract class with a method getInstance() which returns an instance of the Calender class. ANSWER: No! You cannot make an instance of an abstract class. An abstract class has to be sub-classed. If you have an abstract class and you want to use a method which has been implemented, you may need to subclass that abstract class, instantiate your subclass and then call that method. QUESTION: What is the output of x
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF