<< < 1 2 3 4 5 6 7 8 9 10 11 > >>   Sort: Date

What is more advisable to create a thread, by implementing a Runnable interface or by extending Thread class?
What is more advisable to create a thread, by implementing a Runnable interface or by extending Thread class? Strategically speaking, threads created by implementing Runnable interface are more advisable. If you create a thread by extending a thread class, you cannot extend any other class. If you c...
2012-05-17, 2549👍, 0💬

Can you have virtual functions in Java?
Can you have virtual functions in Java? Yes, all functions in Java are virtual by default. This is actually a pseudo trick question because the word "virtual" is not part of the naming convention in Java (as it is in C++, C-sharp and VB.NET), so this would be a foreign concept for someone who has on...
2012-05-16, 2541👍, 0💬

Does a class inherit the constructors of its superclass?
Does a class inherit the constructors of its superclass? A class does not inherit constructors from any of its superclasses.
2012-07-20, 2539👍, 0💬

If a method is declared as protected, where may the method be accessed?
If a method is declared as protected, where may the method be accessed? A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.
2012-06-21, 2537👍, 0💬

What is the immediate superclass of the Dialog class?
What is the immediate superclass of the Dialog class? Window.
2012-10-05, 2524👍, 0💬

What is the difference between the File and RandomAccessFile classes?
What is the difference between the File and RandomAccessFile classes? The File class encapsulates the files and directories of the local file system. The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.
2013-01-08, 2522👍, 0💬

What can go wrong if you replace &emp;&emp; with &emp; in the following code: String a=null; if (a!=null && a.length()&gt;10) {
What can go wrong if you replace &emp;&emp; with &emp; in the following code: String a=null; if (a!=null && a.length()&gt;10) {...} A single ampersand here would lead to a NullPointerException.
2012-06-19, 2522👍, 0💬

How many methods in the Serializable interface?
How many methods in the Serializable interface? There is no method in the Serializable interface. The Serializable interface acts as a marker, telling the object serialization tools that your class is serializable.
2012-05-28, 2515👍, 0💬

If a class is declared without any access modifiers, where may the class be accessed?
If a class is declared without any access modifiers, where may the class be accessed? A class that is declared without any access modifiers is said to have package or friendly access. This means that the class can only be accessed by other classes and interfaces that are defined within the same pack...
2012-07-19, 2514👍, 0💬

What is a transient variable?
What is a transient variable? A transient variable is a variable that may not be serialized. If you don't want some field to be serialized, you can mark that field transient or static.
2012-05-30, 2513👍, 0💬

What is the difference between Serializalble and Externalizable interface?
What is the difference between Serializalble and Externalizable interface? When you use Serializable interface, your class is serialized automatically by default. But you can override writeObject() and readObject() two methods to control more complex object serailization process. When you use Extern...
2012-05-29, 2512👍, 0💬

An application needs to load a library before it starts to run, how to code??
An application needs to load a library before it starts to run, how to code?? One option is to use a static block to load a library before anything is called. For example, class Test { static { System.loadLibrary("path-to-li brary-file");} .... } When you call new Test(), the static block will be ca...
2012-05-18, 2510👍, 0💬

What is similarities/difference between an Abstract class and Interface?
What is similarities/difference between an Abstract class and Interface? Differences are as follows: Interfaces provide a form of multiple inheritance. A class can extend only one other class. Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a ...
2012-05-23, 2498👍, 0💬

What is the relationship between synchronized and volatile keyword?
What is the relationship between synchronized and volatile keyword? The JVM is guaranteed to treat reads and writes of data of 32 bits or less as atomic.(Some JVM might treat reads and writes of data of 64 bits or less as atomic in future) For long or double variable, programmers should take care in...
2012-08-28, 2493👍, 0💬

How does multi-threading take place on a computer with a single CPU?
How does multi-threading take place on a computer with a single CPU? The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.
2012-06-08, 2493👍, 0💬

Jack developed a program by using a Map container to hold key/value pairs. He wanted to make a change to the map. He decided to
Jack developed a program by using a Map container to hold key/value pairs. He wanted to make a change to the map. He decided to make a clone of the map in order to save the original data on side. What do you think of it? ? If Jack made a clone of the map, any changes to the clone or the original map...
2012-05-16, 2492👍, 0💬

How is rounding performed under integer division?
How is rounding performed under integer division? The fractional part of the result is truncated. This is known as rounding toward zero.
2012-11-14, 2491👍, 0💬

How the object oriented approach helps us keep complexity of software development under control?
How the object oriented approach helps us keep complexity of software development under control? We can discuss such issue from the following aspects: Objects allow procedures to be encapsulated with their data to reduce potential interference. Inheritance allows well-tested procedures to be reused ...
2012-08-14, 2491👍, 0💬

Can an inner class declared inside of a method access local variables of this method?
Can an inner class declared inside of a method access local variables of this method? It's possible if these variables are final.
2012-06-19, 2485👍, 0💬

What is NullPointerException and how to handle it?
What is NullPointerException and how to handle it? When an object is not initialized, the default value is null. When the following things happen, the NullPointerException is thrown: --Calling the instance method of a null object. --Accessing or modifying the field of a null object. --Taking the len...
2012-05-17, 2478👍, 0💬

What is the purpose of the File class?
What is the purpose of the File class? The File class is used to create objects that provide access to the files and directories of a local file system.
2012-07-27, 2473👍, 0💬

What value does readLine() return when it has reached the end of a file?
What value does readLine() return when it has reached the end of a file? The readLine() method returns null when it has reached the end of a file.
2012-10-05, 2463👍, 0💬

What are three ways in which a thread can enter the waiting state?
What are three ways in which a thread can enter the waiting state? A thread can enter the waiting state by invoking its sleep() method, by blocking on IO, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoki...
2012-06-04, 2452👍, 0💬

Are the imports checked for validity at compile time? e.g. will the code containing an import such as java.lang.ABCD compile?
Are the imports checked for validity at compile time? e.g. will the code containing an import such as java.lang.ABCD compile? Yes the imports are checked for the semantic validity at compile time. The code containing above line of import will not compile. It will throw an error saying,can not resolv...
2013-05-13, 2449👍, 0💬

<< < 1 2 3 4 5 6 7 8 9 10 11 > >>   Sort: Date