Q: What are ClassLoaders?
A: A class loader is an object that is responsible for loading classes. The class ClassLoader is an abstract class.
Q: What is the difference between an Interface and an Abstract class?
A: An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation.
Q: What will happen if static modifier is removed from the signature of the main method?
A: Program throws "NoSuchMethodError" error at runtime .
Q: What is the default value of an object reference declared as an instance variable?
A: Null, unless it is defined explicitly.
Q: Can a top level class be private or protected?
A: No, a top level class can not be private or protected. It can have either "public" or no modifier.
Q: Why do we need wrapper classes?
A: We can pass them around as method parameters where a method expects an object. It also provides utility methods.
Q: What is the difference between error and an exception?
A: An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. Exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be thrown if the specified file does not exist.
Q: Is it necessary that each try block must be followed by a catch block?
A: It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block or a finally block.
Q: When a thread is created and started, what is its initial state?
A: A thread is in the ready state as initial state after it has been created and started.
Q: What is the Locale class?
A: The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region.
Q: What are synchronized methods and synchronized statements?
A: Synchronized methods are methods that are used to control access to an object. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.
Q: What is runtime polymorphism or dynamic method dispatch?
A: Runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. In this process, an overridden method is called through the reference variable of a superclass.
Q: What is Dynamic Binding(late binding)?
A: Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run-time.
Q: Can constructor be inherited?
A: No, constructor cannot be inherited.
Q: What are the advantages of ArrayList over arrays?
A: ArrayList can grow dynamically and provides more powerful insertion and search mechanisms than arrays.
Q: Why deletion in LinkedList is fast than ArrayList?
A: Deletion in linked list is fast because it involves only updating the next pointer in the node before the deleted node and updating the previous pointer in the node after the deleted node.
Q: How do you decide when to use ArrayList and LinkedList?
A: If you need to frequently add and remove elements from the middle of the list and only access the list elements sequentially, then LinkedList should be used. If you need to support random access, without inserting or removing elements from any place other than the end, then ArrayList should be used.
Q: What is a Values Collection View ?
A: It is a collection returned by the values() method of the Map Interface, It contains all the objects present as values in the map.
Q: What is dot operator?
A: The dot operator(.) is used to access the instance variables and methods of class objects.It is also used to access classes and sub-packages from a package.
Q: Where and how can you use a private constructor?
A: Private constructor is used if you do not want other classes to instantiate the object and to prevent subclassing.T
Q: What is type casting?
A: Type casting means treating a variable of one type as though it is another type.
Q: Describe life cycle of thread?
A: A thread is a execution in a program. The life cycle of a thread include:
- Newborn state
- Runnable state
- Running state
- Blocked state
- Dead state
Q: What is the difference between the >> and >>> operators?
A: The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that have been shifted out.
Q: Which method of the Component class is used to set the position and size of a component?
A: setBounds() method is used for this purpose.
Q: What is the range of the short type?
A: The range of the short type is -(2^15) to 2^15 - 1.
Q: What is the immediate superclass of Menu?
A: MenuItem class
Q: Does Java allow Default Arguments?
A: No, Java does not allow Default Arguments.
Q: Which number is denoted by leading zero in java?
A: Octal Numbers are denoted by leading zero in java, example: 06
Q: Which number is denoted by leading 0x or 0X in java?
A: Hexadecimal Numbers are denoted by leading 0x or 0X in java, example: 0XF
Q: Break statement can be used as labels in Java?
A: Yes, an example can be break one;
Q: Where import statement is used in a Java program?
A: Import statement is allowed at the beginning of the program file after package statement.
Q: Explain suspend() method under Thread class>
A: It is used to pause or temporarily stop the execution of the thread.
Q: Explain isAlive() method under Thread class?
A: It is used to find out whether a thread is still running or not.
Q: What is currentThread()?
A: It is a public static method used to obtain a reference to the current thread.
Q: Explain main thread under Thread class execution?
A: The main thread is created automatically and it begins to execute immediately when a program starts. It ia thread from which all other child threads originate.
Q: Life cycle of an applet includes which steps?
A: Life cycle involves the following steps:
- Initialization
- Starting
- Stopping
- Destroying
- Painting
Q: Why is the role of init() method under applets?
A: It initializes the applet and is the first method to be called.
Q: Which method is called by Applet class to load an image?
A: getImage(URL object, filename) is used for this purpose.
Q: Define code as an attribute of Applet?
A: It is used to specify the name of the applet class.
Q: Define canvas?
A: It is a simple drawing surface which are used for painting images or to perform other graphical operations.
Q: Define Network Programming?
A: It refers to writing programs that execute across multiple devices (computers), in which the devices are all connected to each other using a network.
No comments:
Post a Comment