Comments in Java
Just as in the case of C++ and C, Java supports two types of comments namely, single line
comments and multi-line comments. The syntax for these types of comments are as
follows:
Single line comment:
//
Multiple line comment:
/**/
All characters that exist in the comments region are simply ignored by the Java compiler.
Using Blank Lines:
Any line that is only composed of whitespace characters or comments is considered a
blank line. These lines are just ignored by the compiler and are not included in the
executable.
Inheritance:
Java supports inheritance. In other words, it is possible to derive one class from another
class in this programming language. For instance, if you need to create a new class, which
is an extension of an existing class, then you can simply derive this new class from an
existing class. This allows the new class to access the elements already implemented in the
existing class. In this case, the new class is called the derived class and the existing class is
referred to as the super class.
Interfaces:
As mentioned previously, Java is all about interaction between objects. The manner in
which different objects communicate with each other is defined in what is called an
‘interface.’ Moreover, interfaces are also an important aspect of the inheritance feature of
java. As part of an interface, the methods that can be used by a derived or sub-class are
declared. However, all the methods declared as usable for the subclass must be
implemented in the subclass.
Do'stlaringiz bilan baham: |