Posts tagged java Classes and Methods
Classes and Methods
50) Which are keywords in Java?
Ans : d and e
51) When must the main class and the file name coincide?
Ans :When class is declared public.
52) What are different modifiers?
Ans : public, private, protected, default, static, trancient, volatile, final, abstract.
53) What are access modifiers?
Ans : public, private, protected, default.
54) What is meant by “Passing by value” and ” Passing by reference”?
Ans : objects – pass by reference
Methods – pass by value
55) Is a class a subclass of itself?
Ans : A class is a subclass itself.
56) What modifiers may be used with top-level class?
Ans : public, abstract, final.
57) What is an example of polymorphism?
Ans : c
Ref Link contributor : http://www.hudihudi.com/placement/java/java24.htm
Permanent link to Java Tutorials / Java Interview Questions: http://www.freshersinterviewquestions.com/java-classes-and-methods-2
Classes and Methods
34) A constructor is automatically called when an object is instantiated
35) When may a constructor be called without specifying arguments?
a. When the default constructor is not called
b. When the name of the constructor differs from that of the class
c. When there are no constructors for the class
36) Each class in java can have a finalize method
Ans: a. hudihudi.com
37) When an object is referenced, does this mean that it has been identified by the finalizer method for garbage collection?
38) Because finalize () belongs to the java.lang.Object class, it is present in all ___.
39) Identify the true statements about finalization.
a.A class may have only one finalize method
b.Finalizers are mostly used with simple classes
c.Finalizer overloading is not allowed
40) When you write finalize() method for your class, you are overriding a finalizer
inherited from a super class.
Ref Link contributor : http://www.hudihudi.com/placement/java/java22.htm
Permanent link to Java Tutorials / Java Interview Questions:http://www.freshersinterviewquestions.com/classes-and-methods/