Java Language | 10 Minute‐Test 20


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 operators can be used to concatenate two or more String objects?

A.
+
B.
+=
C.
&
D.
||

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

operator + is used to concatenate strings, Example String s = “i ” + “like ” + “java”; String s contains “I like java”

2.

Which of these methods is an alternative to getChars() that stores the characters in an array of bytes?

A.
getBytes()
B.
GetByte()
C.
giveByte()
D.
Give Bytes()

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

getBytes() stores the character in an array of bytes. It uses default character to byte conversions provided by platform.

3.

What will s2 contain after following lines of code?
String s1 = “one”;
String s2 = s1.concat(“two”)

A.
one
B.
two
C.
onetwo
D.
twoone

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Two strings can be concatenated by using concat() method.

4.

Which of these method of class StringBuffer is used to concatenate the string representation to the end of invoking string?

A.
concat()
B.
append()
C.
join()
D.
concatenate()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

5.

What will s2 contain after following lines of code?
StringBuffer s1 = “one”;
StringBuffer s2 = s1.append(“two”)

A.
one
B.
two
C.
onetwo
D.
twoone

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Two strings can be concatenated by using append() method.

6.

Which of these methods is used to compare a specific region inside a string with another specific region in another string?

A.
regionMatch()
B.
match()
C.
RegionMatches()
D.
regionMatches()

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

7.

Which of these is a mechanism for naming and visibility control of a class and its content?

A.
Object
B.
Packages
C.
Interfaces
D.
None of the Mentioned.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Packages are both naming and visibility control mechanism. We can define a class inside a package which is not accessible by code outside the package.

8.

Which of these can be used to fully abstract a class from its implementation?

A.
Objects
B.
Packages
C.
Interfaces
D.
None of the Mentioned.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

9.

Which of these is a process of converting a simple data type into a class?

A.
type wrapping
B.
type conversion
C.
type casting
D.
None of the Mentioned.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

10.

Which of the following methods is a method of wrapper Integer for obtaining hash code for the invoking object?

A.
int hash()
B.
int hashcode()
C.
int hashCode()
D.
Integer hashcode()
Submit your test now to view the Results and Statistics with answer explanation.