Raja has Published 469 Articles

Importance of isDaemon() method in Java?

raja

raja

Updated on 23-Nov-2023 10:29:10

559 Views

A daemon thread is a low-priority thread in java which runs in the background and mostly created by JVM for performing background tasks like Garbage Collection(GC). If no user thread is running then JVM can exit even if daemon threads are running. The only purpose of a daemon thread is to ... Read More

When to use fillInStackTrace() method in Java?

raja

raja

Updated on 23-Nov-2023 09:28:44

2K+ Views

The fillInStackTrace() is an important method of Throwable class in Java. The stack trace can be useful to determine where exactly the exception is thrown. There may be some situations where we need to rethrow an exception and find out where it is rethrown, we can use the fillInStackTrace() method ... Read More

Importance of StringReader class in Java?

raja

raja

Updated on 23-Nov-2023 09:13:26

317 Views

The StringReader class is s subclass of a Reader class and it can be used to read the character stream in the form of a string which acts as a source to StringReader. The StringReader class overrides all the methods from a Reader class. The important methods of StringReader class ... Read More

How many ways to make an object eligible for GC in Java?

raja

raja

Updated on 23-Nov-2023 09:07:55

489 Views

The process of destroying unreferenced objects is called a Garbage Collection(GC). Once an object is unreferenced it is considered as an unused object, hence JVM automatically destroys that object. There are various ways to make an object eligible for GC. By nullifying a reference to an object We can set all the available ... Read More

What is the importance of a StringWriter in Java?

raja

raja

Updated on 22-Nov-2023 12:03:35

178 Views

The StringWriter class is s subclass of Writer class and it writes the String to an output stream. To write a string, this character stream collects the string into a string buffer and then constructed a string. The buffer of StringWriter automatically grows according to data. The important methods of ... Read More

What is the importance of Runtime class in Java?

raja

raja

Updated on 22-Nov-2023 09:53:24

1K+ Views

The java.lang.Runtime class is a subclass of Object class, can provide access to various information about the environment in which a program is running. The Java run-time environment creates a single instance of this class that is associated with a program. The Runtime class does not have any public constructors, so ... Read More

What are the steps to read static members in a Java class?

raja

raja

Updated on 22-Nov-2023 09:34:23

455 Views

A static variable gets created at the time of class loading even before the execution of a static block and the purpose of the static block is to assign value to the static variables. A static variable stores a value that is shared between all instances of the class it ... Read More

Why an interface cannot implement another interface in Java?

raja

raja

Updated on 22-Nov-2023 09:29:18

12K+ Views

An interface cannot implement another interface in Java. An interface in Java is essentially a special kind of class. Like classes, the interface contains methods and variables. Unlike classes, interfaces are always completely abstract. An interface is defined just like a class except for the keyword interface in place of a class, ... Read More

Can we define an abstract class with no abstract methods in Java?

raja

raja

Updated on 22-Nov-2023 09:15:56

11K+ Views

Yes, we can declare an abstract class with no abstract methods in Java. An abstract class means that hiding the implementation and showing the function definition to the user. An abstract class having both abstract methods and non-abstract methods. For an abstract class, we are not able to create an object directly. But ... Read More

How to use the SimpleDateFormat class to convert a Java Date to a formatted String?

raja

raja

Updated on 21-Nov-2023 16:11:34

155 Views

The Java SimpleDateFormat class provides convert between a Java String to a Date or Date to String. Example import java.util.Date; import java.text.SimpleDateFormat; import java.util.Calendar; public class SimpleDateFormatTest { public static void main(String[] args) { // get today's date Date today = Calendar.getInstance().getTime(); ... Read More

Advertisements