What is the difference between System.out, System.in and System.err streams in Java?

Swarali Sree
Published on 04-Jan-2018 15:09:57
All the programming languages provide support for standard I/O where the user's program can take input from a keyboard and then produce an output on the computer screen. Similarly, Java provides the following three standard streams:Standard Input: This is used to feed the data to user's program and usually a ... Read More

What are file operations in Java?

Monica Mona
Published on 04-Jan-2018 15:40:30
File class provides various methods to perform respective file operations.canRead(): This method tests whether the application can read the file denoted by this abstract pathname. It returns true if and only if the file specified by this abstract pathname exists and can be read by the application; false otherwise.canWrite(): This ... Read More

How can dead thread be restarted in Java?

Sai Subramanyam
Published on 04-Jan-2018 17:07:05
A thread goes through various stages in its lifecycle. For example, a thread is born, started, runs, and then dies. New − A new thread begins its life cycle in the new state. It remains in this state until the program starts the thread. It is also referred to ... Read More

What is concurrency in Java?

Swarali Sree
Published on 04-Jan-2018 17:12:51
The ability to run multiple programs or parts of programs (threads) in parallel is known as concurrency.A multi-threaded program contains two or more parts that can run concurrently and each part can handle a different task at the same time making optimal use of the available resources especially when your ... Read More

What is the Thread class in Java?

karthikeya Boyini
Published on 04-Jan-2018 17:21:34
The java.lang.Thread class is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently. Following are the important points about Thread −Every thread has a priority. Threads with higher priority are executed in preference to threads with lower ... Read More

Which method must be implemented by all threads in Java?

Monica Mona
Published on 04-Jan-2018 17:25:54
While creating a thread class we must override the run() method of the Thread class. This method provides an entry point for the thread and you will put your complete business logic inside this method.Exampleclass ThreadDemo extends Thread {    private String threadName;    ThreadDemo( String name) {   ... Read More

What does the method remove(int) do in java?

Govinda Sai
Published on 04-Jan-2018 17:40:22
The remove(int index) method of the java.util.ArrayList class removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).Exampleimport java.util.ArrayList; public class ArrayListDemo {    public static void main(String[] args) {       ArrayList<Integer> arrlist = new ArrayList<Integer>(5); ... Read More

When a thread is created and started, what is its initial state?

Samual Sam
Published on 04-Jan-2018 17:47:30
When a new thread begins its life cycle in the new state. It remains in this state until the program starts the thread. It is also referred to as a born thread.After this newly born thread is started, the thread becomes runnable. A thread in this state is considered to ... Read More

Where and how can I create a private constructor in Java?

Swarali Sree
Published on 04-Jan-2018 17:50:10
We can use a private contractor in a Java while creating a singleton class. The Singleton's purpose is to control object creation, limiting the number of objects to only one. Since there is only one Singleton instance, any instance fields of a Singleton will occur only once per class, just ... Read More

What does the method elementAt(int index) do in java?

Vikyath Ram
Published on 05-Jan-2018 10:19:10
The elementAt(int index) method is used to get the component at the specified index/location of the vector.Exampleimport java.util.Vector; public class VectorDemo {    public static void main(String[] args) {       Vector<Integer> vec = new Vector<Integer>(4);       vec.add(4);       vec.add(3);       vec.add(2); ... Read More