What are the high-level thread states

The high-level thread states are ready, running, waiting, and dead. In Java, threads can be in various high-level states, and these states are typically represented by the Thread.State enumeration. The high-level thread states in Java are as follows: NEW: A thread that has been created but not yet started with the start() method. RUNNABLE: A … Read more

What is the relationship between the Canvas class and the Graphics class

A Canvas object provides access to a Graphics object via its paint() method. In Java, the Canvas class and the Graphics class are often used together for drawing graphics in a graphical user interface (GUI). Here’s the relationship between these two classes: Canvas Class: The Canvas class is part of the Abstract Window Toolkit (AWT) package (java.awt). It provides … Read more

How are Java source code files named

within the file. A source code file may contain at most one public class or interface. If a public class or interface is defined A Java source code file takes the name of a public class or interface that is defined within a source code file, then the source code file must take the name … Read more

What is an abstract method

An abstract method is a method whose implementation is deferred to a subclass. In Core Java, an abstract method is a method that is declared without providing an implementation in the class where it is declared. It is meant to be overridden by subclasses that extend the class containing the abstract method. The abstract method … Read more

What is the purpose of the wait(), notify(), and notifyAll() methods

The wait(), notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object’s wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object’s notify() or notifyAll() methods. In Java, the wait(), notify(), and notifyAll() methods are used for inter-thread communication and synchronization. … Read more