InfyTQ Arrays and String Quiz 2

Question 1

Time: 00:00:00
Which of these method of class StringBuffer is used to extract a substring from a String object?

substring()

substring()

Substring()

Substring()

SubString()

SubString()

None of the mentioned

None of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
What will s2 contain after following lines of code?

 StringBuffer s1 = “prep”;

 StringBuffer s2 = s1.append(“insta”)

prep

prep

insta

insta

prepinsta

prepinsta

instaprep

instaprep

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
Which of these method of class StringBuffer is used to get the length of sequence of characters?

length()

length()

capacity()

capacity()

Length()

Length()

 Capacity()

 Capacity()

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
Examine the following program fragment:

 

  int[] array = { 1, 4, 3, 6, 8, 2, 5};

  int what = array[0];

 

  // scan the array

  for ( int index=0; index < array.length; index++ )

  { 

    if ( array[ index ] > what )   

      what = array[ index ];  

  }

  System.out.println( what );

1

1

5

5

1 2 3  4 5

1 2 3  4 5

8

8

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
 Examine the following program fragment:

 

  int[] array = { 1, 4, 3, 6, 8, 2, 5};

  int what = array[0];

 

  // scan the array

  for ( int index=0; index < array.length; index++ )

  { 

    if ( array[ index ] < what )   

      what = array[ index ];  

  }

  System.out.println( what ); 

5

5

1

1

1 4 3 6 8 2 5

1 4 3 6 8 2 5

8

8

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Which of the following are incorrect form of StringBuffer class constructor?

StringBuffer()

StringBuffer()

StringBuffer(int size)

StringBuffer(int size)

StringBuffer(String str)

StringBuffer(String str)

StringBuffer(int size , String str)

StringBuffer(int size , String str)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
 What will be the output of below statements?

String s = "prepinsta"; 

System.out.println(s.charAt(s.toUpperCase().length()));

Convert “Z” to int 90 and prints “90

Convert “Z” to int 90 and prints “90

Runtime Exception

Runtime Exception

Prints “z”

Prints “z”

Prints “Z”

Prints “Z”

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
Ques 20 

 What will be the output of below statements?

String s1 = "Prepinsta"; String s2 = "Prepinsta"; String s3 = new String("Prepinsta");

 System.out.print(s1 == s2);

System.out.print(s1 == s3);

. truefalse

. truefalse

truetrue

truetrue

falsefalse

falsefalse

 falsetrue

 falsetrue

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
Which of the following statements are True for StringBuffer and StringBuilder?

StringBuilder is not thread-safe.

StringBuilder is not thread-safe.

StringBuffer is thread safe because its methods are synchronized.

StringBuffer is thread safe because its methods are synchronized.

StringBuilder was introduced in Java 1.4

StringBuilder was introduced in Java 1.4

StringBuffer and StringBuilder are immutable.

StringBuffer and StringBuilder are immutable.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
What will be the output of below statements?

String s1 = "abc"; String s2 = "def"; System.out.println(s1.compareTo(s2));

zero

zero

true

true

-3

-3

false

false

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/0

Accuracy

0%

Comments