0
Q:

Which of the following statements are equal for a variable declared in the interface ?

1. int X=10
2. public int X=10
3. public static final int X=10

A) Only 1 and 2 are equal B) Only 2 and 3 are equal
C) All are unequal D) All are equal

Answer:   D) All are equal



Explanation:

All the statements are equal because inside an interface a variable declared will be public static final by default 

Subject: Java
Job Role: IT Trainer
Q:

Why static methods cannot access non static variables or methods?

Answer

A static method cannot access non static variables or methods because static methods doesnt need the object to be accessed. So if a static method has non static variables or non static methods which has instantiated variables they will no be intialized since the object is not created and this could result in an error.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

9 3211
Q:

What is the importance of finally block in exception handling ?

Answer

A finally block will always be executed, whether or not an exception is actually thrown. Even in the case where the catch statement is missing and an exception is thrown, the finally block will still be executed. Last thing to mention is that the finally block is used to release resources like I/O buffers, database connections, etc.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

11 5047
Q:

What is the difference between Serial and Throughput Garbage collector ?

Answer

The throughput garbage collector uses a parallel version of the young generation collector and is meant to be used with applications that have medium to large data sets. On the other hand, the serial collector is usually adequate for most small applications (those requiring heaps of up to approximately 100MB on modern processors).

Report Error

View answer Workspace Report Error Discuss

Subject: Java

5 3762
Q:

When is the finalize() called ? What is the purpose of finalization ?

Answer

The finalize method is called by the garbage collector, just before releasing the object’s memory. It is normally advised to release resources held by the object inside the finalize method.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 3363
Q:

What is the purpose of garbage collection in Java, and when is it used ?

Answer

The purpose of garbage collection is to identify and discard those objects that are no longer needed by the application, in order for the resources to be reclaimed and reused.


 

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 2579
Q:

What’s the difference between Enumeration and Iterator interfaces ?

Answer

Enumeration is twice as fast as compared to an Iterator and uses very less memory. However, the Iterator is much safer compared to Enumeration, because other threads are not able to modify the collection object that is currently traversed by the iterator. Also, Iteratorsallow the caller to remove elements from the underlying collection, something which is not possible with Enumerations.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 5190
Q:

What do you know about the big-O notation and can you give some examples with respect to different data structures ?

Answer

The Big-O notation simply describes how well an algorithm scales or performs in the worst case scenario as the number of elements in a data structure increases. The Big-O notation can also be used to describe other behavior such as memory consumption. Since the collection classes are actually data structures, we usually use the Big-O notation to chose the best implementation to use, based on time, memory and performance. Big-O notation can give a good indication about performance for large amounts of data.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 3279
Q:

What are the basic interfaces of Java Collections Framework ?

Answer

Java Collections Framework provides a well designed set of interfaces and classes that support operations on a collections of objects. The most basic interfaces that reside in the Java Collections Framework are:


Collection, which represents a group of objects known as its elements.


Set, which is a collection that cannot contain duplicate elements.


List, which is an ordered collection and can contain duplicate elements.


Map, which is an object that maps keys to values and cannot contain duplicate keys.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 1883