0% found this document useful (0 votes)
7 views

0 - Javamcq Part1 41

This JSON summarizes a document containing several code snippets and questions about Java arrays. The document contains multiple code examples demonstrating how to declare and access elements in arrays. It also includes the expected output for each code snippet.

Uploaded by

Priyansh Gangani
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)
7 views

0 - Javamcq Part1 41

This JSON summarizes a document containing several code snippets and questions about Java arrays. The document contains multiple code examples demonstrating how to declare and access elements in arrays. It also includes the expected output for each code snippet.

Uploaded by

Priyansh Gangani
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/ 1

system.out.print(marks.

length + "," + marks[1]);


a) 2,65
b) 3,95
c) 3,65
d) compiler error
ans: c
63-what is the output of the below java code snippet?
int[] balls = {};
system.out.print(balls.length);
a) 0
b) -1
c) 1
d) compiler error
ans: a
64-which is the correct way of knowing array size in java?
a) ary.length()
b) ary.length
c) ary->length()
d) ary->length
ans: b
65-what is the output of the below java program with arrays?
String[] colors = {"red";"yellow";"white"};
system.out.print(colors[2]);
a) red
b) yellow
c) white
d) compiler error
ans: d
66-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
ans: c
67-what is the output of the below java program?
int ages[3] = {25, 27, 30};
system.out.println(ages[1]);
a) 25
b) 27
c) 30
d) compile error
ans: d

You might also like