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 diamond problem?

Answer

The diamond problem is an ambiguity that can occur when a class multiply inherits from two classes that both descend from a common super class

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1742
Q:

What is the difference between array and ArrayList ?

Answer

Array is collection of same data type. Array size is fixed, It cannot be expanded.


 


But ArrayList is a growable collection of objects.ArrayList is a part of Collections Framework and can work with only objects.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1437
Q:

How will you define an abstract class?

Answer

An abstract class is defined with the keyword abstract Eg:
public abstract class MyClass { }

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1347
Q:

What is an abstract class?

Answer

An abstract class is an incomplete class. An abstract class is defined with the keyword abstract . We cannot create an object of the abstract class because it is not complete. It sets a behavioral protocol for all its child classes.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1620
Q:

What is the difference between a constructor and a method?

Answer

A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator. We cannot invoke a constructor directly.


 


A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1835
Q:

What is a class, member and local variable?

Answer

Variables declared within a method are local variables. Variables declared within the class are member variables.  Variables declared within the class with static modifier are class variables 

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1354
Q:

What is polymorphism?

Answer

It is the ability of an object to behave differently on different situations for the same message.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1562
Q:

What is JAR file?

Answer

A JAR file (short for Java Archive) is a ZIP file used to distribute a set of Java classes. It is used to store compiled Java classes and associated metadata that can constitute a program

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1821