Raja has Published 760 Articles

Interface variables are static and final by default in Java, Why?

raja

raja

Updated on 11-Feb-2020 07:58:12

18K+ Views

An interface defines a protocol of behavior and not how we should be implemented. A class that implements an interface adheres to the protocol defined by that interface.Interface variables are static because java interfaces cannot be instantiated on their own. The value of the variable must be assigned in a ... Read More

Can we declare a main method as private in Java?

raja

raja

Updated on 11-Feb-2020 07:49:21

4K+ Views

Yes, we can declare the main method as private in Java.It compiles successfully without any errors but at the runtime, it says that the main method is not public.Example:class PrivateMainMethod {    private static void main(String args[]){        System.out.println("Welcome to Tutorials Point");     } }The above code ... Read More

How to set Temporary and Permanent Paths in Java?

raja

raja

Updated on 11-Feb-2020 07:39:28

20K+ Views

There are two ways to set the path in java, First is Temporary Path and second is Permanent Path.Setting Temporary PathOpen command prompt in WindowsCopy the path of jdk/bin directory where java located (C:\Program Files\Java\jdk_version\bin)Write in the command prompt: SET PATH=C:\Program Files\Java\jdk_version\bin and hit enter command.Setting Permanent PathGo to My ... Read More

How can we convert character array to a Reader in Java?

raja

raja

Updated on 11-Feb-2020 05:55:23

276 Views

The CharArrayReader is a subclass of Reader class and it can implement a character buffer that can be used as a character input stream. The CharArrayReader reads characters from a character array either completely or partially starting from an offset. The important methods of a CharArrayReader class are close(), mark(), read(), skip() and ... Read More

Why the transient variable is not serialized in Java?

raja

raja

Updated on 11-Feb-2020 05:25:59

654 Views

The Serialization is a process to persists java objects in the form of a sequence of bytes that includes the object’s data as well as information about the object’s type and the types of data stored in the object. The Serialization is the translation of Java object’s values/states to bytes to ... Read More

How can we Implement a Stack using Queue in Java?

raja

raja

Updated on 11-Feb-2020 05:21:33

979 Views

A Stack is a subclass of Vector class and it represents last-in-first-out (LIFO) stack of objects. The last element added at the top of the stack (In) can be the first element to be removed (Out) from the stack.A Queue class extends Collection interface and it supports the insert and removes operations using a first-in-first-out (FIFO). We ... Read More

What can cause the "cannot find symbol" error in Java?

raja

raja

Updated on 10-Feb-2020 13:35:22

12K+ Views

The “cannot find symbol” error occurs mainly when we try to reference a variable that is not declared in the program which we are compiling, it means that the compiler doesn’t know the variable we are referring to.Some possible causes for “Cannot find symbol” to occur areUsing a variable that ... Read More

How can we implement a moving text using a JLabel in Java?

raja

raja

Updated on 10-Feb-2020 13:34:34

1K+ Views

A JLabel is a subclass of JComponent class and an object of JLabel provides text instructions or information on a GUI. A JLabel can display a single line of read-only text, an image or both text and an image. A JLabel can explicitly generate a PropertyChangeListener interface. We can also implement a moving text in a JLabel by ... Read More

How can we set the background/foreground color for individual column of a JTable in Java?

raja

raja

Updated on 10-Feb-2020 12:52:14

3K+ Views

A JTable is a subclass of JComponent class for displaying complex data structures. A JTable component can follow the Model View Controller (MVC) design pattern for displaying the data in rows and columns. A JTable can generate TableModelListener, TableColumnModelListener, ListSelectionListener, CellEditorListener, RowSorterListener interfaces. We can change the background and foreground color for each ... Read More

What is the purpose of Process class in Java?

raja

raja

Updated on 10-Feb-2020 12:49:33

1K+ Views

The java.lang.Process is a subclass of Object class and it can describe the processes that are started by the exec() method of Runtime class. A Process object controls the process and gets information about it. The Process class is an abstract class, therefore, it cannot be instantiated. The important method s of the Process ... Read More

Advertisements