Java Language | 10 Minute‐Test 23


Instruction

  • Total number of questions : 10.
  • Time alloted : 10 minutes.
  • Each question carry 1 mark.
  • No Negative marks
  • DO NOT refresh the page.
  • All the best :-).

1.

Which of these constructors is used to create an empty String object?

A.
String()
B.
String(void)
C.
String(0)
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None .

2.

Which of these methods can be used to convert all characters in a String into a character array?

A.
charAt()
B.
both getChars() & charAt()
C.
both toCharArray() & getChars()
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

charAt() return one character only not array of character.

3.

Which of the following statement is correct?

A.
replace() method replaces all occurrences of one character in invoking string with another character.
B.
replace() method replaces only first occurances of a character in invoking string with another character.
C.
replace() method replaces all the characters in invoking string with another character.
D.
replace() replace() method replaces last occurrence of a character in invoking string with another character.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

replace() method replaces all occurrences of one character in invoking string with another character.

4.

Which of the following statement is correct?

A.
reverse() method reverses all characters.
B.
reverseall() method reverses all characters.
C.
replace() method replaces first occurrence of a character in invoking string with another character.
D.
replace() method replaces last occurrence of a character in invoking string with another character.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

reverse() method reverses all characters. It returns the reversed object on which it was called.

5.

Which of the following are incorrect form of StringBuffer class constructor?

A.
StringBuffer()
B.
StringBuffer(int size)
C.
StringBuffer(String str)
D.
StringBuffer(int size , String str)

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

6.

Which of these data type value is returned by equals() method of String class?

A.
char
B.
int
C.
boolean
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

equals() method of string class returns boolean value true if both the string are equal and false if they are unequal.

7.

Which of the following is correct way of importing an entire package ‘pkg’?

A.
import pkg.
B.
Import pkg.
C.
import pkg.*
D.
Import pkg.*

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Operator * is used to import the entire package.

8.

Which of the following is correct way of implementing an interface salary by class manager?

A.
class manager extends salary {}
B.
class manager implements salary {}
C.
class manager imports salary {}
D.
None of the mentioned.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

9.

Which of the following is method of wrapper Float for converting the value of an object into byte?

A.
bytevalue()
B.
byte byteValue()
C.
Bytevalue()
D.
Byte Bytevalue().

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

10.

Which of the following is method of wrapper Integer for converting the value of an object into int?

A.
bytevalue()
B.
int intValue();
C.
Bytevalue()
D.
Byte Bytevalue().
Submit your test now to view the Results and Statistics with answer explanation.