What is a static class in Java?

Published on 02-Jan-2018 17:28:29
You cannot use the static keyword with a class unless it is an inner class. A static inner class is a nested class which is a static member of the outer class. It can be accessed without instantiating the outer class, using other static members. Just like static members, a ... Read More

How to create an array of linked lists in java?

Abhinanda Shri
Published on 02-Jan-2018 18:04:52
A linked list is a sequence of data structures, which are connected together via links.To create an array of linked lists, create required linked lists and, create an array of objects with them.ExampleLive Demoimport java.util.LinkedList; public class ArrayOfLinkedList {    public static void main(String args[]) {       ... Read More

What are packages in Java?

Published on 02-Jan-2018 18:08:13
Packages are used in Java in order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier, etc. java.lang − bundles the fundamental classes. java.io − classes for input, output functions are bundled in this package. Programmers can define ... Read More

How to convert Byte Array to Image in java?

V Jyothi
Published on 03-Jan-2018 09:35:50
Java provides ImageIO class for reading and writing an image. To convert a byte array to an image.Create a ByteArrayInputStream object by passing the byte array (that is to be converted) to its constructor.Read the image using the read() method of the ImageIO class (by passing the ByteArrayInputStream objects to ... Read More

What are method local inner classes in Java?

Published on 03-Jan-2018 09:54:42
In Java, we can write a class within a method and this will be a local type. Like local variables, the scope of the inner class is restricted to the method.A method-local inner class can be instantiated only within the method where the inner class is defined. The following program ... Read More

What are primitive data types in Java?

Johar Ali
Published on 03-Jan-2018 11:03:16
Java supports eight predefined primitive datatypes they are −byteByte data type is an 8-bit signed two's complement integerMinimum value is -128 (-2^7)Maximum value is 127 (inclusive)(2^7 -1)Default value is 0Byte data type is used to save space in large arrays, mainly in place of integers, since a byte is four ... Read More

What are literals in Java?

Johar Ali
Published on 03-Jan-2018 11:25:05
A literal is a source code representation of a fixed value. They are represented directly in the code without any computation. Literals can be assigned to any primitive type variable. Example byte a = 68; char a = 'A' byte, int, long, and short can be ... Read More

How multiple inheritance is implemented using interfaces in Java?

Published on 03-Jan-2018 12:07:14
Java does not support multiple inheritance. This means that a class cannot extend more than one class. Therefore, following is illegal −Examplepublic class extends Animal, Mammal{}However, a class can implement one or more interfaces, which has helped Java get rid of the impossibility of multiple inheritance.The extends keyword is used ... Read More

What are unchecked exceptions in Java?

Sharon Christine
Published on 04-Jan-2018 12:02:11
An unchecked exception is the one which occurs at the time of execution. These are also called as Runtime Exceptions. These include programming bugs, such as logic errors or improper use of an API. Runtime exceptions are ignored at the time of compilation. If you have declared an array of size ... Read More

What is boxing and unboxing in Java?

Rahul Sharma
Published on 03-Jan-2018 12:32:44
Wrapper classes are those whose objects wraps a primitive data type within them. In the java.lang package java provides a separate class for each of the primitive data type namely Byte, Character, Double, Integer, Float, Long, Short.Converting primitive datatype to object is called boxing.ExampleInteger obj = new Integer ("2526");Whereas, converting an ... Read More