Register Now

Forget Password

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Basic java properties

1. The output of the Java compiler is bytecode, which leads to the security and portability of the Java code. It is a highly developed set of instructions that are designed to be executed by the Java runtime system known as Java Virtual Machine (JVM). The Java programs executed by the JVM that makes the code portable and secure. Because JVM prevents the code from generating its side effects. The Java code is portable, as the same byte code can run on any platform

2. 

The Java language does not support pointers; some of the major reasons are listed below:

  • One of the major factors of not using pointers in Java is security concerns. Due to pointers, most of the users consider C-language very confusing and complex. This is the reason why Green Team (Java Team members) has not introduced pointers in Java.
  • Java provides an effective layer of abstraction to the developers by not using pointers in Java.

Java is dynamic, architecture-neutral, and object-oriented programming language.

3. 

  1. The static block will execute whenever the class is loaded by JVM.
  2. Instance block will execute whenever an object is created, and they are invoked before the constructors. For example, if there are two objects, the instance block will execute two times for each object.
  3. The constructor will execute after the instance block, and it also execute every time the object is created.
  4. A method is always executed at the end

4. 

In Java, Unicode characters can be used in string literals, comments, and commands, and are expressed by Unicode Escape Sequences. A Unicode escape sequence is made up of the following articles:

  • A backslash '\' (ASCII character 92)
  • A 'u' (ASCII 117)
  • One or more additional 'u' characters that are optional.
  • A four hexadecimal digits (a character from 0 - 9 or a-f or A-F)

5. In Java, the return type of hashCode() method is an integer, as it returns a hash code value for the object.

6. 

For every long literal to be recognized by Java, we need to add L character at the end of the expression. It can be either uppercase (L) or lowercase (l) character. However, it is recommended to use uppercase character instead of lowercase because the lowercase (l) character is hard to distinguish from the uppercase (i) character.

For example,

  1. Lowercase l: 0x466rffl
  2. Uppercase L: 0nhf450L

7. In Java, whenever we divide any number (double, float, and long except integer) by zero, it results in infinity. According to the IEEE Standard for Floating-Point Arithmetic (IEEE 754), if we divide 1/0 will give positive infinity, -1/0 will give negative infinity, and 0/0 will give NaN. But on dividing an integer by zero, it throws a runtime exception, i.e., java.lang.ArithmeticException.

8. 

The Javadoc is a tool that is used to generate API documentation in HTML format from the Java source files. In other words, it is a program (tool) that reads a collection of source files into an internal form.

The Javadoc command line syntax is,
Javadoc [options] [packagenames] [sourcefiles] [@files]

The javap tool is used to get the information of any class or interface. It is also known as a disassembler. The javaw command is identical to java that displays a window with error information, and the javah command is used to generate native method functions.

8. The Random class is available in the java.util package. An object of the Random class is used to generate a series of pseudorandom numbers. And the object of this class is a thread-safe and cryptographically insecure object. The Random class provides a variety of methods that are used to create random numbers of type integers, float, long, double, etc.

9. 

The nameless objects are basically referred to as anonymous objects. The anonymous objects do not have any names. We can also say that, when an object is initialized but is not assigned to any reference variable, it is called an anonymous object. For example, new Employee();.

If we assign it to a reference variable like,

Employee emp = new Employee();

In the above code, emp is a reference variable. Therefore, the above object is not anonymous, as it is assigned to a reference variable.

10. 

An interface with no methods and fields is known as the marker interface. In other words, an empty interface (containing no fields and methods) is called a marker interface. In Java, the most commonly used marker interfaces are Serializable, Cloneable, Remote, and ThreadSafe interfaces. Marker interfaces are also known as the Tag interface. It is used to tell the JVM or compiler that the particular class has special behavior.

Following is the code snippet of a maker interface:

public interface Cloneable 
{
    // empty 
}