Core Java - Interview Questions and Answers

211. Can we define a variable in an interface ?and what type it should be ?

Ans : Yes we can define a variable in an interface. They are implicitly final and static.

212. What is difference between interface and an abstract class?

Ans : All the methods declared inside an Interface are abstract. Where as abstract class must have at least one abstract method and others may be concrete or abstract.
In Interface we need not use the keyword abstract for the methods.

213. By default, all program import the java.lang package.

Ans : True

214. Java compiler stores the .class files in the path specified in CLASSPATH
environmental variable.

Ans : False

215. User-defined package can also be imported just like the standard packages.

Ans : True

216. When a program does not want to handle exception, the ______class is used.

Ans : Throws

217. The main subclass of the Exception class is _______ class.

Ans : RuntimeException

218. Only subclasses of ______class may be caught or thrown.

Ans : Throwable

219. Any user-defined exception class is a subclass of the _____ class.

Ans : Exception

220. The catch clause of the user-defined exception class should ______ its
Base class catch clause.

Ans : Exception

Post a Comment

Mới hơn Cũ hơn