Core Java Interview Questions – Set 07

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 priority and other factors.

What is UNICODE?-

Unicode is used for internal representation of characters and strings and it uses 16 bits to represent each other.

What is JVM (Java Virtual Machine) ?

JVM stands for Java Virtual Machine. It’s an abstract computer or virtual computer which runs the compiled java programs. Actually JVM is a software implementation which stands on the top of the real hardware platform and operating system. It provides abstraction between the compiled java program and the hardware and operating system. So the compiled program does not have to worry about what hardware and operating system he has to run in, it’s all handled by the JVM and thus attaining portability. All Java programs are compiled in to bytecodes. JVM can only understand and execute Java bytecodes. we can visualize Java bytecodes as machine language for JVM. Java compiler takes the .java files and compiles it to a “bytecode” file with .class file extension. Compiler generates one class file for one source file.

What are Native methods in Java ?

There may be times when we want to call subroutines which are written in some other language other than Java like C++, VB6 etc.

Can a for statement loop indefinitely

Yes, a for statement can loop indefinitely. For example, consider the following:

for(;;) ;

What is an I/O filter?-

An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another.

How can you copy one array in to a different array?

System.arraycopy(myOldArray, 0, myNewArray, 0, length);+

What is a reflection package?-

java. lang. reflect package has the ability to analyze itself in runtime.

What is a task’s priority and how is it used in scheduling

A task’s priority is an integer value that identifies the relative order in which it should be executed with respect to other tasks. The scheduler attempts to schedule higher priority tasks before lower priority tasks.

What modifiers may be used with a top-level class

A top-level class may be public, abstract, or final.