InfyTQ Arrays and String Quiz 1

Question 1

Time: 00:00:00
 What is the length of the following array: byte[] data = { 12, 34, 9, 0, -62, 88 };

1

1

5

5

6

6

12

12

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

Please login to submit your explanation

Question 2

Time: 00:00:00
Which of these class is   superclass of String and StringBuffer class?

 java.util

 java.util

ArrayList

ArrayList

java.lang

java.lang

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

Question 3

Time: 00:00:00
  What is the output of the following code fragment:

  int[] arr = { 2, 4, 6, 8, 10, 1, 3, 5, 7, 9 }

    for ( int index= 0 ; index < 5 ; index++  )

      System.out.print(  arr[ index ] + "  "  );

2 4 6 8

2 4 6 8

 2 4 6 8 10

 2 4 6 8 10

 2 4 6 8 10 1

 2 4 6 8 10 1

 2 4 6 8 10 1 3 5 7 9

 2 4 6 8 10 1 3 5 7 9

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

Please login to submit your explanation

Question 4

Time: 00:00:00
What is the output of the following code fragment:

   int[] arr = { 2, 4, 6, 8, 10, 1, 3, 5, 7, 9 };

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

      System.out.print(  arr[ index ] + "  "  );

 2 4 6 8

 2 4 6 8

2 4 6 8 10

2 4 6 8 10

 2 4 6 8 10 1

 2 4 6 8 10 1

  2 4 6 8 10 1 3 5 7 9

  2 4 6 8 10 1 3 5 7 9

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

Please login to submit your explanation

Question 5

Time: 00:00:00
 Which of these operators can be used to concatenate two or more String objects?

+

+

+=

+=

&

&

||

||

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

Please login to submit your explanation

Question 6

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

CHARAT()

CHARAT()

charat()

charat()

charAt()

charAt()

ChatAt()

ChatAt()

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

Please login to submit your explanation

Question 7

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

string()

string()

String(void)

String(void)

 String(0)

 String(0)

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

Question 8

Time: 00:00:00
What is the output of the following code fragment:

   
int[] egArray = { 2, 4, 6, 8, 10, 1, 3, 5, 7, 9 };
   for ( int index= 0 ; index < egArray.length ; index = index + 2  )
      System.out.print(  egArray[ index ] + "  "  );

2 4 6 8 10 1 3 5 7 9

2 4 6 8 10 1 3 5 7 9

4 8 1 5 9

4 8 1 5 9

2 6 10 3 7

2 6 10 3 7

2 6 10 3 7 0

2 6 10 3 7 0

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

Please login to submit your explanation

Question 9

Time: 00:00:00
 Does a programmer always know how long an array will be when the program is being written?

Yes---the program will not compile without the length being declared.

Yes---the program will not compile without the length being declared.

No---the array object is created when the program is running, and the length might change from run to run.

No---the array object is created when the program is running, and the length might change from run to run.

Yes---otherwise the program will not run correctly.

Yes---otherwise the program will not run correctly.

 No---arrays can grow to whatever length is needed.

 No---arrays can grow to whatever length is needed.

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

Please login to submit your explanation

Question 10

Time: 00:00:00
Fill in the blanks of the following code fragment so that the elements of the array are printed in reverse order starting with the last element.

 int[] egArray = { 2, 4, 6, 8, 10, 1, 3, 5, 7, 9 };

    for ( int index= ________ ; _____________ ; ______________ )

      System.out.print(  egArray[ index ] + "  "  );

index = 0; index < egArray.length; index--

index = 0; index < egArray.length; index--

 index = length; index < 0; index--

 index = length; index < 0; index--

 index = egArray.length-1; index >= 0; index--

 index = egArray.length-1; index >= 0; index--

index = length-1; index > 0; index--

index = length-1; index > 0; index--

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

Please login to submit your explanation

["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%

Get over 200+ Courses under One Subscription

mute

Don’t settle Learn from the Best with PrepInsta Prime Subscription

Learn from Top 1%

One Subscription, For Everything

The new cool way of learning and upskilling -

Limitless Learning

One Subscription access everything

Job Assistance

Get Access to PrepInsta Prime

Top Faculty

from FAANG/IITs/TOP MNC's

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.