3
Q:

 What is the string contained in s after following lines of code?

StringBuffer s = new StringBuffer(“Hello”); s.deleteCharAt(0);  ?

A) llo B) Hllo
C) ello D) H

Answer:   C) ello



Explanation:

deleteCharAt() method deletes the character at the specified index location and returns the resulting StringBuffer object.

So after deleting the character at 0 ie 'H', the string returns 'ello' as the output.

Subject: Java
Job Role: Analyst , IT Trainer
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 5586
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 3970
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 3595
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 2795
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 5488
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 3549
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 2199
Q:

What is the difference between processes and threads ?

Answer

- A process is an execution of a program, while a Thread is a single execution sequence within a process.


- A process can contain multiple threads. A Thread is sometimes called a lightweight process.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2600