Infosys - https://www.wisdomjobs.com/e-university/infosys-core-java-interview-questions.html
When A Thread Is Created And Started, What Is Its Initial State?
A thread is in the ready state after it has been created and started.
What Invokes A Thread's Run() Method?
After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.
What Is A Marker Interface?
An interface with no methods. Example: Serializable, Remote, Cloneable
What Interface Do You Implement To Do The Sorting?
Comparable
What Is The Major Difference Between Linkedlist And Arraylist?
LinkedList are meant for sequential accessing. ArrayList are meant for random accessing.
To What Value Is A Variable Of The String Type Automatically Initialized?
Null
What Value Does Readline() Return When It Has Reached The End Of A File?
Null
What Is Driver Manager?
The basic service to manage set of JDBC drivers.
What Are The High-level Thread States?
The high-level thread states are ready, running, waiting, and dead.
Is Null A Keyword?
The null is not a keyword.
What Is The Immediate Superclass Of The Dialog Class?
Window
What Is A Hashcode?
hashcode value for the object which is unique for every object.
What Modifiers May Be Used With An Inner Class That Is A Member Of An Outer Class?
A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.
What Is The Relationship Between The Canvas Class And The Graphics Class?
A Canvas object provides access to a Graphics object via its paint() method.
What Are The Different Driver Types Available In Jdbc?
A JDBC-ODBC bridge A native-API partly Java technology-enabled driver A net-protocol fully Java technology-enabled driver A native-protocol fully Java technology-enabled driver For more information.
How Are Java Source Code Files Named?
A Java source code file takes the name of a public class or interface that is defined within the file. A source code file may contain at most one public class or interface. If a public class or interface is defined within a source code file, then the source code file must take the name of the public class or interface. If no public class or interface is defined within a source code file, then the file must take on a name that is different than its classes and interfaces. Source code files use the .java extension.
What Is A Native Method?
A native method is a method that is implemented in a language other than Java.
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).
What Is The Argument Type Of A Program's Main() Method?
A program's main() method takes an argument of the String[] type.
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.
When A Thread Blocks On I/o, What State Does It Enter?
A thread enters the waiting state when it blocks on I/O.
What Is A Transient Variable?
A transient variable is a variable that may not be serialized.
What Is The Difference Between Interface And Abstract Class?
Abstract class defined with methods. Interface will declare only the methods. Abstract classes are very much useful when there is a some functionality across various classes. Interfaces are well suited for the classes which varies in functionality but with the same method signatures.
What Is An Abstract Method?
An abstract method is a method whose implementation is deferred to a subclass.
Can An Anonymous Class Be Declared As Implementing An Interface And Extending A Class?
An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.
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.
How Many Times May An Object's Finalize() Method Be Invoked By The Garbage Collector?
An object's finalize() method may only be invoked once by the garbage collector.
Name Three Subclasses Of The Component Class.
Box.Filler, Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar, or TextComponent.
What Is Clipping?
Clipping is the process of confining paint operations to a limited area or shape.
How Are Commas Used In The Intialization And Iteration Parts Of A For Statement?
Commas are used to separate multiple statements within the initialization and iteration parts of a for statement.
What Is The Algorithm Used In Thread Scheduling?
Fixed priority scheduling.
Which Containers May Have A Menubar?
Frame.
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.
What Is Composition?
Holding the reference of the other class within some other class is known as composition.
What Is The Catch Or Declare Rule For Method Declarations?
If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.
What Is Nested Class?
If all the methods of a inner class is static then it is a nested class.
What Is The Difference Between The Boolean & Operator And The && Operator?
If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.
What Is Inner Class?
If the methods of the inner class can only be accessed via the instance of the inner class, then it is called inner class.
What Is The Purpose Of Assert Keyword
In order to validate certain expressions. It effectively replaces the if block and automatically throws the AssertionError on failure. This keyword should be used for the critical arguments. Meaning, without that the method does nothing.
What Is Aggregation?
It is a special type of composition. If you expose all the methods of a composite class and route the method call to the composite method through its reference, then it is called aggregation.
What Is The Purpose Of Abstract Class?
It is not an instantiable class. It provides the concrete implementation for some/all the methods. So that they can reuse the concrete functionality by inheriting the abstract class.
What Is Singleton?
It is one of the design pattern. This falls in the creational pattern of the design pattern. There will be only one instance for that entire JVM. You can achieve this by having the private constructor in the class.
What Is Class.forname() Does And How It Is Useful?
It loads the class into the ClassLoader. It returns the Class. Using that you can get the instance ( "class-instance".newInstance() ).
What Is The Eligibility For A Object To Get Cloned?
It must implement the Cloneable interface
What Must A Class Do To Implement An Interface?
It must provide all of the methods in the interface and identify the interface in its implements clause.
How Does Java Handle Integer Overflows And Underflows?
It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.
What Is The Immediate Superclass Of Menu?
MenuItem.
Does The Jdbc-odbc Bridge Support Multiple Concurrent Open Statements Per Connection?
No
Is Jdbc-odbc Bridge Multi-threaded?
No
Can A Byte Object Be Cast To A Double Value?
No. An object cannot be cast to a primitive value.
Which Class Is The Immediate Superclass Of The Menucomponent Class?
Object.
How Are Observer And Observable Used?
Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.
What Are Order Of Precedence And Associativity, And How Are They Used?
Order of precedence determines the order in which operators are evaluated in expressions. Associatity determines whether an expression is evaluated left-to-right or right-to-left.
What Is The Immediate Superclass Of The Applet Class?
Panel.
What Do You Mean By Rmi And How It Is Useful?
RMI is a remote method invocation. Using RMI, you can work with remote object. The function calls are as though you are invoking a local variable. So it gives you a impression that you are working really with a object that resides within your own JVM though it is somewhere.
What Is The Protocol Used By Rmi?
RMI-IIOP
What Is Skeleton And Stub? What Is The Purpose Of Those?
Stub is a client side representation of the server, which takes care of communicating with the remote server. Skeleton is the server side representation. But that is no more in use... it is deprecated long before in JDK.
Name Two Subclasses Of The Textcomponent Class.
TextField and TextArea.
Which Java Operator Is Right Associative?
The = operator is right associative.
What Is The Difference Between The >> And >>> Operators?
The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that have been shifted out.
Name Three Component Subclasses That Support Painting
The Canvas, Frame, Panel, and Applet classes support painting.
What Is The Difference Between A Menuitem And A Checkboxmenuitem?
The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked.
What Is The Collections Api?
The Collections API is a set of classes and interfaces that support operations on collections of objects.
Which Java.util Classes And Interfaces Support Event Handling?
The EventObject class and the EventListener interface support event processing.
What Is The Gregoriancalendar Class?
The GregorianCalendar class provides support for traditional Western calendars.
What Is An Iterator Interface?
The Iterator interface is used to step through the elements of a Collection.
What Is The List Interface?
The List interface provides support for ordered collections of objects.
Which Containers Use A Flowlayout As Their Default Layout?
The Panel and Applet classes use the FlowLayout as their default layout.
What Is The Vector Class?
The Vector class provides the capability to implement a growable array of objects.
Which Containers Use A Border Layout As Their Default Layout?
The Window, Frame and Dialog classes use a border layout as their default layout.
Which Characters May Be Used As The Second Character Of An Identifier, But Not As The First Character Of An Identifier?
The digits 0 through 9 may not be used as the first character of an identifier but they may be used after the first character of an identifier.
What Is The Purpose Of The Finally Clause Of A Try-catch-finally Statement?
The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.
What Class Is The Top Of The Awt Event Hierarchy?
The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy.
What Is The Preferred Size Of A Component?
The preferred size of a component is the minimum component size that will allow the component to display normally.
What Is The Purpose Of Finalization?
The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.
What Is The Purpose Of The Runtime Class?
The purpose of the Runtime class is to provide access to the Java runtime system.
What Value Does Read() Return When It Has Reached The End Of A File?
The read() method returns -1 when it has reached the end of a file.
What Method Is Used To Specify A Container's Layout?
The setLayout() method is used to specify a container's layout.
Is Sizeof A Keyword?
The sizeof operator is not a keyword.
What Method Is Invoked To Cause An Object To Begin Executing As A Separate Thread?
The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread.
What Is The Purpose Of The Wait(), Notify(), And Notifyall() Methods?
The wait(), notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object's wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object's notify() or notifyAll() methods..
What Is A Thread?
Thread is a block of code which can execute concurrently with other threads in the JVM.
Why Do Threads Block On I/o?
Threads block on I/O (that is enters the waiting state) so that other threads may execute while the I/O Operation is performed.
What Is The Use Of Serializable?
To persist the state of an object into any perminant storage device.
What Is Hash-collision In Hashtable And How It Is Handled In Java?
Two different keys with the same hash value. Two different entries will be kept in a single hash bucket to avoid the collision.
30. (Advanced java)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.
How Will You Get The Platform Dependent Values Like Line Separator, Path Separator, Etc., ?
Using Sytem.getProperty(...) (line.separator, path.separator, ...)
What Is The Difference Between Yielding And Sleeping?
When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.
What State Does A Thread Enter When It Terminates Its Processing?
When a thread terminates its processing, it enters the dead state.
What Is Synchronization And Why Is It Important?
With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often leads to significant errors.
What Are Wrapped Classes?
Wrapped classes are classes that allow primitive types to be accessed as objects.
Can A Double Value Be Cast To A Byte?
Yes, a double value can be cast to a byte.
Can A Lock Be Acquired On A Class?
Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object..
What Is The Significance Of Listiterator?
You can iterator back and forth.
Can You Instantiate The Math Class?
You can't instantiate the math class. All the methods in this class are static. And the constructor is not public.
What Are The Methods In Object?
clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString
What Is The Final Keyword Denotes?
final keyword denotes that it is the final implementation for that method or variable or class. You can't override that method/variable/class any more.
Can A For Statement Loop Indefinitely?
for(;;) ;
Which Method Of The Component Class Is Used To Set The Position And Size Of A Component?
setBounds() method is used to set the position and size of a component.
Which Container Method Is Used To Cause A Container To Be Laid Out And Redisplayed?
validate() method is used to cause a container to be laid out and redisplayed.