What is the difference between preemptive scheduling and time slicing

Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on … Read more

What is the immediate superclss of the Applet class

Panel. In Core Java, the immediate superclass of the Applet class is the Panel class. The Applet class extends the Panel class, which, in turn, extends the Container class, and the Container class extends the Component class. Therefore, the class hierarchy looks like this: Object > Component > Container > Panel > Applet So, the … Read more

Can an object’s finalize() method be invoked while it is reachable

An object’s finalize() method cannot be invoked by the garbage collector while the object is still reachable. However, an object’s finalize() method may be invoked by other objects. No, an object’s finalize() method cannot be invoked while the object is reachable. The finalize() method in Java is called by the garbage collector before reclaiming the memory occupied by an … Read more

What restrictions are placed on the location of a package statement within a source code file?

A package statement must appear as the first line in a source code file (excluding blank lines and comments). In Java, the package statement must be the first statement in a Java source file, before any import statements or class declarations. The correct answer to the question about the restrictions on the location of a … Read more

Does garbage collection guarantee that a program will not run out of memory

Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection. No, garbage collection in Java does not guarantee that … Read more