Sie sind auf Seite 1von 8

7/26/2014 Arrays | GeeksQuiz

http://geeksquiz.com/java/arrays/ 1/8
Question 1
A java array is always an object
Length of array can be changed after creation of array
Arrays in Java are always allocated on heap
Question 2
GeeksQuiz
Computer science mock tests for geeks
Search
Home
Latest Questions
Articles
C/C++ Programs
Contribute
Books
Subscribe
Arrays
Which of the following is FALSE about arrays on Java
A
B
C
Discuss it
Predict the output?

// file name: Main.java
public class Main {
public static void main(String args[]) {
int arr[] = {10, 20, 30, 40, 50};
7/26/2014 Arrays | GeeksQuiz
http://geeksquiz.com/java/arrays/ 2/8
10 20 30 40 50
Compiler Error
10 20 30 40
Question 3
0
0
garbage value
garbage value
Compiler Error
Exception
A
B
C
Discuss it
A
B
C
D
Discuss it
for(int i=0; i < arr.length; i++)
{
System.out.print(" " + arr[i]);
}
}
}
class Test {
public static void main(String args[]) {
int arr[2];
System.out.println(arr[0]);
System.out.println(arr[1]);
}
}
7/26/2014 Arrays | GeeksQuiz
http://geeksquiz.com/java/arrays/ 3/8
Question 4
0
0
garbage value
garbage value
Compiler Error
Exception
Question 5
A
B
C
D
Discuss it
class Test {
public static void main(String args[]) {
int arr[] = new int[2];
System.out.println(arr[0]);
System.out.println(arr[1]);
}
}
public class Main {
public static void main(String args[]) {
int arr[][] = new int[4][];
arr[0] = new int[1];
arr[1] = new int[2];
arr[2] = new int[3];
arr[3] = new int[4];

int i, j, k = 0;
for (i = 0; i < 4; i++) {
for (j = 0; j < i + 1; j++) {
arr[i][j] = k;
k++;
}
}
for (i = 0; i < 4; i++) {
for (j = 0; j < i + 1; j++) {
System.out.print(" " + arr[i][j]);
k++;
}
System.out.println();
7/26/2014 Arrays | GeeksQuiz
http://geeksquiz.com/java/arrays/ 4/8
Compiler Error
0
1 2
3 4 5
6 7 8 9
0
0 0
0 0 0
0 0 0 0
9
7 8
4 5 6
0 1 2 3
Question 6
Same
Not Same
A
B
C
D
Discuss it
Output of following Java program?
A
}
}
}
class Test
{
public static void main (String[] args)
{
int arr1[] = {1, 2, 3};
int arr2[] = {1, 2, 3};
if (arr1 == arr2)
System.out.println("Same");
else
System.out.println("Not same");
}
}
7/26/2014 Arrays | GeeksQuiz
http://geeksquiz.com/java/arrays/ 5/8
Question 7
Same
Not Same
Question 8
B
Discuss it
Output of following Java program?
A
B
Discuss it
import java.util.Arrays;
class Test
{
public static void main (String[] args)
{
int arr1[] = {1, 2, 3};
int arr2[] = {1, 2, 3};
if (Arrays.equals(arr1, arr2))
System.out.println("Same");
else
System.out.println("Not same");
}
}
class Test
{
public static void main (String[] args)
{
int arr1[] = {1, 2, 3};
int arr2[] = {1, 2, 3};
if (arr1.equals(arr2))
System.out.println("Same");
else
System.out.println("Not same");
}
}
7/26/2014 Arrays | GeeksQuiz
http://geeksquiz.com/java/arrays/ 6/8
Same
Not same
A
B
Discuss it
There are 8 questions to complete.

0 Like Tweet 0

0
Categories
Articles (61)
C (6)
C++ (15)
Data Structures (20)
DBMS (1)
Java (2)
Operating Systems (1)
Searching and Sorting (9)
Programs (33)
Quizzes (1,405)
Aptitude (1)
Computer Science Quizzes (1,404)
Algorithms (146)
C (205)
C++ (123)
GeeksQuiz
6,153 people like GeeksQuiz.
Facebook social plugin
Like
7/26/2014 Arrays | GeeksQuiz
http://geeksquiz.com/java/arrays/ 7/8
Data Structures (131)
DBMS (1)
GATE (719)
Java (51)
Operating Systems (28)
Recent Discussions
Vaibhav
let x = the given expression. Now squaring both...
GATE | GATE-CS-2014-(Set-2) | Question 5 10 hours ago
Vaibhav
Here 1st letter of each term in order are: A C...
GATE | GATE CS 2012 | Question 65 11 hours ago
sonu
I am getting compilation error as prog.c: In...
C | Pointer Basics | Question 5 15 hours ago
GeeksforGeeks
Please note that the expression is x++ which...
C | Operators | Question 24 20 hours ago
Sharwari Phadnis
As it is said that it is evaluated from left to...
C | Operators | Question 24 21 hours ago
GeeksforGeeks
@All Thanks for pointing this out We have...
Stack | Set 4 (Evaluation of Postfix Expression) 21 hours ago
Valid XHTML Strict 1.0
Powered by WordPress & MooTools | MiniMoo 1.3.4
7/26/2014 Arrays | GeeksQuiz
http://geeksquiz.com/java/arrays/ 8/8

Das könnte Ihnen auch gefallen