-
-
-
How are Observer and Observable used
Objects that subclass the Observable class maintain a list of observers. When anObservable object isupdated it invokes the update() method of each of its observers to notify the observersthat it has changedstate. The Observer interface is implemented by objects that observe Observable objects.
-
What is synchronization and why is it important
With respect to multithreading, synchronization is the capability to control the access ofmultiple threads toshared resources. Without synchronization, it is possible for one thread to modify ashared object whileanother thread is in the process of using or updating that object's value. This often leadsto significanterrors.
-
How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8characters
Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set usesonly 7 bits, it isusually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns.UTF-16 uses 16-bit and larger bit patterns.
-
What is the difference between preemptive scheduling and time slicing
Under preemptive scheduling, the highest priority task executes until it enters the waitingor dead states ora higher priority task comes into existence. Under time slicing, a task executes for apredefined slice oftime and then reenters the pool of ready tasks. The scheduler then determines which taskshould executenext, based on priority and other factors.
-
What are order of precedence and associativity, and how are they used
Order of precedence determines the order in which operators are evaluated inexpressions. Associatitydetermines whether an expression is evaluated left-to-right or right-to-left
-
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 beexecuted withrespect to other tasks. The scheduler attempts to schedule higher priority tasks beforelower priority tasks.
-
In which package are most of the AWT events that support the event-delegationmodel defined
Most of the AWT-related events of the event-delegation model are defined in thejava.awt.event package.The AWTEvent class is defined in the java.awt package.
-
What is the difference between the Boolean & operator and the && operator
If an expression involving the Boolean & operator is evaluated, both operands areevaluated. Then the &operator is applied to the operand. When an expression involving the && operator isevaluated, the firstoperand is evaluated. If the first operand returns a value of true then the second operandis evaluated. The&& operator is then applied to the first and second operands. If the first operandevaluates...
-
What is the difference between a break statement and a continue statement
A break statement results in the termination of the statement to which it applies (switch,for, do, or while).A continue statement is used to end the current loop iteration and return control to theloop statement.
-
What is the advantage of the event-delegation model over the earlier eventinheritancemodel
The event-delegation model has two advantages over the event-inheritance model. First,it enables eventhandling to be handled by objects other than the ones that generate the events (or theircontainers). Thisallows a clean separation between a component's design and its use. The other advantageof the eventdelegationmodel is that it performs much better in applications where many events aregenerated....
-
What is the purpose of the wait(), notify(), and notifyAll() methods
The wait(),notify(), and notifyAll() methods are used to provide an efficient way forthreads to wait for ashared resource. When a thread executes an object's wait() method, it enters the waitingstate. It only entersthe ready state after another thread invokes the object's notify() or notifyAll() methods.
-
How are Java source code files named
A Java source code file takes the name of a public class or interface that is defined withinthe file. A sourcecode file may contain at most one public class or interface. If a public class or interface isdefined within asource code file, then the source code file must take the name of the public class orinterface. If no publicclass or interface is defined within a source code file, then the file must...
-
What is an object's lock and which object's have locks
An object's lock is a mechanism that is used by multiple threads to obtain synchronizedaccess to the object.A thread may execute a synchronized method of an object only after it has acquired theobject's lock. Allobjects and classes have locks. A class's lock is acquired on the class's Class object.
-
What is the difference between the Reader/Writer class hierarchy and theInputStream/OutputStream class hierarchy
The Reader/Writer class hierarchy is character-oriented, and theInputStream/OutputStream class hierarchyis byte-oriented.
-
If a class is declared without any access modifiers, where may the class beaccessed
A class that is declared without any access modifiers is said to have package access. Thismeans that theclass can only be accessed by other classes and interfaces that are defined within thesame package.
-
Is "abc" a primitive value
The String literal "abc" is not a primitive value. It is a String object.
-
What is the relationship between an event-listener interface and an eventadapterclass
An event-listener interface defines the methods that must be implemented by an eventhandler for aparticular kind of event. An event adapter provides a default implementation of an eventlistenerinterface.
-
How can a GUI component handle its own events
A component can handle its own events by implementing the required event-listenerinterface and addingitself as its own event listener.
Java Interview Questions
Ans