|
Page 6 of 9
Inheritance is a process by which objects of a class acquire the
properties of the objects of another class. It supports the concept of
hierarchical classification. It not only allows objects to be reused,
but also allows the creation of new objects by extending the existing
ones. By using the... [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..]
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..]
Numeric promotions are used to convert the operands in a numeric
expression to a common type before an operation is performed between
the operands. Numeric promotion is a property of the specific
definitions of the built-in operations and not a Java language feature.
It is applied to the operands... [read more..]
The + operator concatenates two strings, producing a new String object as the result. For example,
String amt = "50";
String s = "John gave me " + amt + "dollars";
System.out.println(s);
This code will display the string "John gave me 50 dollars".
The + operator may also be used to...
[read more..]
Encapsulation is the mechanism that binds together data structure
(attributes) and behavior (operations) of an object into a single unit.
It keeps the internal implementation details of the object hidden from
other objects. In other words, encapsulation works as a protective
sheet that prevents... [read more..]
The == operator is generally used to check the equality of primitive
type values. It evaluates to true if the two values are the same.
Otherwise, it evaluates to false. The == comparison operator may also
be used to determine whether two object references refer to the same
object. It... [read more..]
Character literals are 16 bit Unicode characters that are used to
represent a single character. They are generally used to initialize
variables declared as char. They can also be converted into integer
types and manipulated with integer operators. Character literals are
formed by enclosing a... [read more..]
Variables associated with the instance of a class are called instance
variables. Whenever a class is instantiated, the runtime system creates
a separate copy of each instance variable defined by the class.
Therefore, each instance of a class has its own copy of all instance
variables defined by... [read more..]
The for loop is the most versatile looping construct. It is used to
continuously execute a block of code until a particular condition is
satisfied. It comprises three parts: initialization, condition, and
iteration. The initialization portion is generally an expression that
sets the value of... [read more..]
|