|
Page 6 of 14
A named inner class that is declared within the body of a method is
called a local class. A local class is not a member of any class. An
inner class declared inside a method is private to the method.
Therefore, it can neither be marked with an access modifier (public,
private, or protected) nor......[read more]
A constructor is used to create an object that is an instance of a
class. It has the same name as the class in which it resides. A
constructor for a class is declared in the same way as a method is
declared, but it is declared without a return type. A constructor can
be marked with one of the......[read more]
A nested class that is not declared as static is called a member class.
A member class is also commonly known as an inner class. It is
associated with an instance of its enclosing class. A member class has
access to all the variables and methods defined in its enclosing class.
There can be......[read more]
A nested class declared as static is called a static nested class. A
static nested class can directly access only static variables and
methods defined in its enclosing class. However, it cannot refer
directly to instance variables or methods defined in its enclosing
class. It can refer them only......[read more]
A class defined within the body of another class is known as a nested
class, and the class that encloses it is known as its enclosing class.
The scope of a nested class is bounded by the scope of its enclosing
class. A nested class has unlimited access to the members of its
enclosing class, even......[read more]
A block of code that appears just after the finally statement is called
a finally block. The statements in a finally block are executed
immediately after execution of the try/catch block. The finally block
is optional. However, each try statement must have at least one catch
block or a finally......[read more]
The toString() method returns a String object that gives a description
of the object on which the method is called. The default implementation
of the toString() method is in the Object class with the following
signature: public String toString() Most of the classes override the
toString()......[read more]
Methods declared with the keyword static as modifier are called static
methods or class methods. They are so called because they affect a
class as a whole, not a particular instance of the class. Static
methods are always invoked without reference to a particular instance
of a class. The......[read more]
An exception is an abnormal event that occurs during the execution of a
program. It describes an error occurred at runtime. This error disrupts
the normal flow of instructions in the program. In Java, exceptions are
represented using objects. When an exceptional condition arises within
a......[read more]
A block of code that follows the try statement is called a try block. A
try block is used to enclose the statements that might throw an
exception. The general form of a try block is as follows: try{
//statements } When an exception arises within the try statement,
an......[read more]
|