Q Why Java is platform independent?
Java is called platform independent because of its byte codes which can run on any system irrespective of its underlying operating system.
Advanced Java Interview Questions on Multithreading
Check some more Java Multithreading Interview Questions here.
Q64) What are access specifiers in Java? List all of Java’s access specifiers
Ans. Java’s access specifiers help to control where an instance field/method of a class is accessible. Java has the following access specifiers:
3 How do you create an enum in Java?
The following example code shows how to create a basic enum:
ThreadStates is the enum with fixed constants fields
DEAD. All enums implicitly extend the
java.lang.Enum class and implement the
Comparable interfaces. Enum can have methods also. Learn more about enums in Java.
Q13) What is the difference between multitasking and multithreading?
Ans. Multitasking includes two ways of representation: 1. Preemptive multitasking: where the system terminates the idle process without asking the user. For example Unix/Linux, Windows NT 2. Non-preemptive multitasking: where the system asks the process to give control to other processes for execution. For example Windows 3.1 and Mac OS 9.
Multithreading: 1. Multithreaded programs are the program that extends the functionality of multitasking by dividing the program in the thread and then execute the task as individual threads. 2. Threads run in a different area and each thread utilizes some amount of CPU and memory for execution.
Q14) What is the difference between an Interface and an Abstract class?
Ans. An abstract class can have instance methods that implement a default behaviour. An Interface can only declare constants and instance methods, but cannot implement default behaviour and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class that may have the usual flavours of class members (private, protected, etc.), but has some abstract methods.
Q18) What is an abstract class?
Ans. Abstract class must be extended/subclassed (to be useful). It serves as a template. A class that is abstract may not be instantiated (ie, you may not call its constructor), an abstract class may contain static data. Any class with an abstract method is automatically abstract itself and must be declared as such. A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.