0% found this document useful (0 votes)
156 views3 pages

MCQs - Java Arrays - 2 PDF

The document contains 5 multiple choice questions about arrays in Java. Question 1 asks about the output of a program that assigns elements of one array to another. Question 2 asks about the actual position of an element in an array given its index. Question 3 asks about the default value of primitive data types in an array. Question 4 asks about the output of a program that assigns incrementing values to an array. Question 5 asks about the type of array that contains multiple arrays. The answers provided are: MOUSE, N+1, 0, 2,4,6, and Multidimensional.

Uploaded by

Ashish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
156 views3 pages

MCQs - Java Arrays - 2 PDF

The document contains 5 multiple choice questions about arrays in Java. Question 1 asks about the output of a program that assigns elements of one array to another. Question 2 asks about the actual position of an element in an array given its index. Question 3 asks about the default value of primitive data types in an array. Question 4 asks about the output of a program that assigns incrementing values to an array. Question 5 asks about the type of array that contains multiple arrays. The answers provided are: MOUSE, N+1, 0, 2,4,6, and Multidimensional.

Uploaded by

Ashish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Arrays - 2

MCQs
MCQs
Q1- What is the output of the below Java program with arrays?

public class Polo {

public static void main(String args[])

String[] computer = {"RAM","HDD","MOUSE"};

String[] parts = {computer[0],computer[2]};

System.out.print(parts[1]);

}
A) RAM

B) HDD

C) MOUSE

D) Compiler error

Q2- If an index of an element is N, what is its actual position in the array?


A) N-1

B) N

C) N+1

D) N+2

Q3- What is the default value of byte, short, int or long data type elements of an array in Java?
A) -1

B) 1

C) 0

D) Garbage value

Q4- What is the output of the below Java program?

int balls[], rounds=3;

balls = new int[rounds];

for(int i=0; i<balls.length; i++)

balls[i] = (i+1)*2;

for(int j=0; j<balls.length; j++)

System.out.print(balls[j] + ",");
A) 0,2,4,

B) 2,3,4,

C) 2,4,6,

D) Compiler error

Q5- An array of arrays in Java is called ___ array.


A) Bidirectional

B) Combo

C) Multidimensional

D) Multi-value

Cracking the Coding Interview in JAVA - Foundation


MCQs
Answers:
Ans 1 : MOUSE

Ans 2 : N+1

Ans 3 : 0

Ans 4 : 2,4,6

Ans 5 : Multidimensional

Cracking the Coding Interview in JAVA - Foundation

You might also like