Category Archives: Java

Object Serialization with Inheritance in Java

Prerequisite : – Serialization, Inheritance Serialization is a mechanism of converting the state of an object into a byte stream. Deserialization is the reverse process where the byte stream is used to recreate the actual Java object in memory. This mechanism is used to persist the object. There are some cases of Serialization with respect… Read More »

Java.lang.Class class in Java | Set 1

Java provides a class with name Class in java.lang package. Instances of the class Class represent classes and interfaces in a running Java application. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects. It has no public constructor. Class objects are… Read More »

Double Brace Initialization in Java

When we use a collection in your code, we typically do following. Declare a variable for a temporary collection. Create a new empty collection and store a reference to it in the variable. Put things into the collection. Pass the collection to the method. For example: Output: [one, two, three] Above are normal steps we… Read More »

Operators in Java

Java provides many types of operators which can be used according to the need. They are classified based on the functionality they provide. Some of the types are- Arithmetic Operators Unary Operators Assignment Operator Relational Operators Logical Operators Ternary Operator Bitwise Operators Shift Operators instance of operator Precedence and Associativity Interesting Questions Lets take a… Read More »

Java.Lang.Long class in Java

Long class is a wrapper class for the primitive type long which contains several methods to effectively deal with a long value like converting it to a string representation, and vice-versa. An object of Long class can hold a single long value. There are mainly two constructors to initialise a Long object- Long(long b): Creates… Read More »

Java.lang.Integer class in Java

Integer class is a wrapper class for the primitive type int which contains several methods to effectively deal with a int value like converting it to a string representation, and vice-versa. An object of Integer class can hold a single int value. Constructors: Integer(int b): Creates a Integer object initialized with the value provided. Syntax… Read More »

Interfaces and Inheritance in Java

Prerequisites: Interfaces in Java, Java and Multiple Inheritance A class can extends another class and/ can implement one and more than one interface. Output; Welcome: inside the method m1 Welcome: inside the method m2 Interface inheritance : An Interface can extend other interface. Output: Rohit JIIT An interface can also extend multiple interfaces. Output: Rohit… Read More »

Java.Lang.Short class in Java

Short class is a wrapper class for the primitive type short which contains several methods to effectively deal with a short value like converting it to a string representation, and vice-versa. An object of Short class can hold a single short value. There are mainly two constructors to initialise a Short object- Short(short b): Creates… Read More »

Java.Lang.Byte class in Java

Byte class is a wrapper class for the primitive type byte which contains several methods to effectively deal with a byte value like converting it to a string representation, and vice-versa. An object of Byte class can hold a single byte value. There are mainly two constructors to initialise a Byte object- Byte(byte b): Creates… Read More »

Java.Lang.Double class in Java

Double class is a wrapper class for the primitive type double which contains several methods to effectively deal with a double value like converting it to a string representation, and vice-versa. An object of Double class can hold a single double value. There are mainly two constructors to initialize a Double object- Double(double b) :Creates… Read More »