Author:
Daisy Williams
Aug
20
A constructor without any parameters is known as a default constructor. When a class is defined without any constructor, the Java compiler provides an implicit default constructor. The implicit default constructor is equivalent to the following implementation:
class name(){
super();
}
When the implicit default constructor of a class is invoked, it implicitly calls the no parameter constructor in the superclass. This action taken by a default constructor ensures that the inherited state of the object is initialized properly. In addition, it initializes all the instance variables in the object to the default value depending on their data type.
Author:
Daisy Williams
Feb
12
The Console class is used to create the instance of a console. A console is a character-based unique device that associates with a JVM. The console of a JVM is dependent upon the following two factors:
- The underlying platform
- The manner in which the virtual machine is invoked.
If JVM uses an interactive command line without redirecting the standard input and output streams, then its console will exist and will typically be connected to the keyboard and display from which the virtual machine was launched. If JVM starts automatically, it will typically not have a console. It may be possible that the JVM does not have any console. If JVM has a console, then it is represented by a unique instance of the Console class, which can be obtained by invoking the System.console() method.
Permanent link to this post (135 words, estimated 32 secs reading time)
Author:
Daisy Williams
Feb
11
The LinkedList class defines the following methods for manipulating lists. These are as follows:
void addFirst(E obj): This method inserts an element at the beginning of the list.
void addLast(E obj): This method inserts an element at the end of a list
>E getFirst(): This method is used to retrieve the first element from the list.
E getLast(): This method retrieves the last element from the list.
E removeFirst(): This removes the first element from the list.
E removeLast(): This method removes the last element from the list.
Here, obj specifies the item.
Permanent link to this post (94 words, estimated 23 secs reading time)
Author:
Daisy Williams
Feb
8
Static import is a new feature introduced in j2SE 5.0. It allows the static members of the imported class to be treated as if they were declared in the class that uses them. It is now no longer required to use the static class name and dot operator as was required before. Static imports are of the following two types:
- One in which all the members of a particular static class are imported:
import static packageName.ClassName.*;
- And the other in which only a particular member of a class is imported:
import static packageName.ClassName.membername;
Permanent link to this post (94 words, estimated 23 secs reading time)