java.util.Comparator
java.util.Comparator compares some other class’s instances.
java.lang.Comparable
java.lang.Comparable compares another object with itself.
Differentiate between final, finally and finalize.
The keyword is final. It is used for declaring a constant It prevents a class from producing subclasses.
finally is a code.It always executes when the try block is finished, Unless System.exit() has been called.finalize() is a method, Before discarding by the garbage collector it is invoked.
Differentiate JAR and WAR files
JAR files:
- JAR files is the acronym stands for Java ARchive fles.
- JAR files allow aggregating many files into one,
- JAR is usually used to hold Java classes in a library.
WAR files:
- WAR files is the acronym stands for Web ARchive fles.
- WAR stores XML, java classes, and JavaServer pages
- WAR is mainly used for Web Application purposes.
In a Java , how can you send program messages on the system console, but error messages, to a file?
The class System has a variable out that denotes the standard output.
The standard error device represents the variable err .
Naturally, they both point at the system console.
In this way, the standard output can be sent to the file:
Stream x = new Stream(new FileOutputStream(“error.txt”));
System.setErr(x);
System.Out(x);