Vous êtes sur la page 1sur 2

Core Java FAQ

1) Can an Interface be final? – No

2) What modifiers may be used with an inner class that is a member of an outer class? - An inner
class may be declared as public, protected, private, static, final, or abstract.

3) Can we define private and protected modifiers for variables in interfaces? – No

4) Can there be an abstract class with no abstract methods in it? – Yes

5) Can an Interface have an inner class? - Yes.

6) What are Access Specifiers available in Java? – public, protected, private, default

7) What are transient variables in java? Transient variables are variable that cannot be serialized

8) Can we call finalize() method ? Yes.

9) How can you call a constructor from another constructor? By using this() reference.

10) How can we call a method or variable of the super class from child class? We can use
super.method() or super.variable syntax for this purpose.

11) What are different type of exceptions in Java? – There are two types of exceptions in java. Checked
exceptions and Unchecked exceptions.

12) Can we catch an error in our java program? - Yes. We can. We can catch anything that is derived from
Throwable. Since Error is a sub class of Throwable we can catch an error also.

13) Which is the base class for all classes? – java.lang.Object class

14) What is the difference between String and StringBuffer class? – String is immutable (constant),
their values cannot be changed after they are created. StringBuffer supports mutable objects.

15) What are the different states of a thread? – The different thread states are ready, running, waiting
and dead.

16) What are different types of exceptions in Java? – There are two types of exceptions in java. Checked
exceptions and Unchecked exceptions. Any exception that is is derived from Throwable and Exception is
called checked exception except RuntimeException and its sub classes. Any exception that is derived from
Error and RuntimeException is called unchecked exception. We don't need to explicitly catch a unchecked
exception.

17) What is the difference between readers and streams? – Readers are character oriented where
streams are byte oriented. The readers are having full support for Unicode data

18) How is the difference between thread and process? – A process runs in its own address space. No
two processes share their address space. Threads will run in the same address space of the process that owns
them.

19) How can we create a thread? – A thread can be created by extending Thread class or by implementing
Runnable interface. Then we need to override the method public void run().

20) Is null a keyword? - The null value is not a keyword

Vous aimerez peut-être aussi