Java Array Quiz

Java Array Quiz

University

48 Qs

quiz-placeholder

Similar activities

Math Show what you know 3-4

Math Show what you know 3-4

3rd Grade - University

45 Qs

Memes and School!

Memes and School!

7th Grade - University

47 Qs

Word Within Word #5 & 6

Word Within Word #5 & 6

3rd Grade - University

50 Qs

goto операторы туралы тест

goto операторы туралы тест

University

50 Qs

Data Structure and Algorithm

Data Structure and Algorithm

University

43 Qs

ÔN TẬP CUỐI HỌC KÌ II

ÔN TẬP CUỐI HỌC KÌ II

University

51 Qs

C++ RK1

C++ RK1

University

45 Qs

Quiz Susulan Latihan Soal UTS Teori Bahasa dan Otomata-2022-1

Quiz Susulan Latihan Soal UTS Teori Bahasa dan Otomata-2022-1

University

50 Qs

Java Array Quiz

Java Array Quiz

Assessment

Quiz

Mathematics

University

Hard

Created by

simamkele yawa

Used 3+ times

FREE Resource

48 questions

Show all answers

1.

MULTIPLE SELECT QUESTION

5 mins • 2 pts

Which of the following Array declaration statement is illegal?

int [ ] a [ ] = new int [4] [4];

int a[ ][ ] = new int [4] [4];

int a[ ] [ ] = new int [ ] [4];

int [ ] a [ ] = new int [4] [ ];

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will happen if you try to compile and run the following code ? public class Test { public static void main (String args[]) { int[] arr = new int [] {1,2,3}; System.out.println(arr[1]); } }

1

Error: arr is referenced before it is initialized

2

Error: size of array must be defined

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

In the given Array declaration, which expression returns the output as 5? int [] arr = { 23, 5, 78, 34, 2};

arr.length()

arr[].length()

arr[].length

arr.length

4.

MULTIPLE CHOICE QUESTION

5 mins • 3 pts

What will be the output upon the execution of the following code ? public class Test { public static void main(String[] args) { int j = 5; for (int i = 0; i< j; i++) { if ( i <= j-- ) System.out.print( (i*j) + " "); } } }

0 3 2

1 2 3

0 3 4

1 4 2

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which declaration of the main() method is valid ?

public void main( String args [] )

public void static main( String args [] )

final public static void main(String[] arr)

public static void main( String[] arr)

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code ? public class Test { public static void main(String[] args) { double d = 100.04; float f = d; System.out.println("Float value "+f); } }

100.04

100.0

Compilation Error (lossy conversion from double to float)

100

7.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Is it possible in Java to create arrays of length zero ?

Yes, you can create arrays of any type with length zero.

No, it is not possible to create arrays of length zero in Java.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?