• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Java Interview Questions Answers

Question - 21 : - What is the preferred size of a component?

Answer - 21 : - The preferred size of a component is the minimum component size that will allow the component to display normally.

Question - 22 : - What is Serialization and deserialization ?

Answer - 22 : - Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects.

Question - 23 : - What is the List interface?

Answer - 23 : - The List interface provides support for ordered collections of objects.

Question - 24 : - What do you understand by Synchronization?

Answer - 24 : - Synchronization is a process of controlling the access of shared resources by the multiple threads in such a manner that only one thread can access one resource at a time. In non synchronized multithreaded application, it is possible for one thread to modify a shared object while another thread is in the process of using or updating the object's value. Synchronization prevents such type of data corruption. E.g. Synchronizing a function: public synchronized void Method1 () { // Appropriate method-related code. } E.g. Synchronizing a block of code inside a function: public myFunction (){ synchronized (this) { // Synchronized code here. } }

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

Answer - 25 : - A package statement must appear as the first line in a source code file (excluding blank lines and comments).

Question - 26 : - Two methods have key words static synchronized and synchronized separately. What is the difference between them?

Answer - 26 : - Both are synchronized methods. One is instance method, the other is class method. Method with static modifier is a class method. That means the method belongs to class itself and can be accessed directly with class name and is also called Singleton design. The method without static modifier is an instance method. That means the instance method belongs to its object. Every instance of the class gets its own copy of its instance method. When synchronized is used with a static method, a lock for the entire class is obtained. When synchronized is used with a non-static method, a lock for the particular object (that means instance) of the class is obtained. Since both methods are synchronized methods, you are not asked to explain what is a synchronized method. You are asked to tell the difference between instance and class method. Of course, your explanation to how synchronized keyword works doesn't hurt. And you may use this opportunity to show your knowledge scope.

Question - 27 : - Can a lock be acquired on a class?

Answer - 27 : - Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.

Question - 28 : - What is a Container in a GUI?

Answer - 28 : - A Container contains and arranges other components (including other containers) through the use of layout managers, which use specific layout policies to determine where components should go as a function of the size of the container.

Question - 29 : - What is the Vector class?

Answer - 29 : - The Vector class provides the capability to implement a growable array of objects

Question - 30 : - What is the  difference between preemptive scheduling and time slicing?

Answer - 30 : - 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. Name three Component subclasses that support painting. The Canvas, Frame, Panel, and Applet classes support painting.

Computer Contributors

Rajeev Katiyar
Yes Baroda

Share your email for latest updates


Our partners