Core Java - Interview Questions and Answers

291. Final methods can be overridden.
True/False

Ans : False

292. Declaration of methods as final results in faster execution of the program?
True/False

Ans: True

293. Final variables should be declared in the beginning?
True/False

Ans : True

294. Can we declare variable inside a method as final variables? Why?

Ans : Cannot because, local variable cannot be declared as final variables.

295. Can an abstract class may be final?

Ans : An abstract class may not be declared as final.

296. Does a class inherit the constructors of it's super class?

Ans: A class does not inherit constructors from any of it's super classes.

297. What restrictions are placed on method overloading?

Ans: Two methods may not have the same name and argument list but different return types.

298. What restrictions are placed on method overriding?

Ans : Overridden methods must have the same name , argument list , and return type. The overriding method may not limit the access of the method it overridees.The overriding method may not throw any exceptions that may not be thrown by the overridden method.

299. What modifiers may be used with an inner class that is a member of an outer class?

Ans : a (non-local) inner class may be declared as public, protected, private, static, final or abstract.

300. How super() used with constructors? & An interface contains __ methods.
a)Non-abstract
b)Implemented
c)unimplemented

Ans : super() is used to invoke a super class constructor.
Ans:c

Post a Comment

Mới hơn Cũ hơn