
java quiz
Authored by Giri A
Computers
University
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
public class Main {
public static void main(String[] args) {
int[] arr = {10, 20, 30, 40, 50};
int index = 2;
System.out.println(arr[index + 1]);
}
}
30
40
50
Systax error
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
public class Main {
public static void main(String[] args) {
String str = “Hello, world!”;
System.out.println(str.length());
}
}
13
14
12
Undefined behavior
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
public class Main {
public static void main(String[] args) {
int[] Arr = new int[3];
Arr[1] = 10;
Arr[2] = 20;
Arr = null;
System.out.println(arr[2]);
}
}
0
10
20
NullPointerException
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
public class Main {
public static void main(String[] args) {
int[] arr = new int[10];
Arr = null;
Arr[0] = 5;
System.out.println(arr[0]);
}
}
What will happen?
It will print 5.
It will print 0
It will throw a NullPointerException
It will cause a compilation error.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
public class Main {
public static void main(String[] args) {
int x = 5; // Binary: 0101
x= x << 1;
System.out.println(x);
}
}
5
10
20
2
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
public class Main {
static class Person {
String name;
int age;
Person(String name, int age) {
this.name = name;
this.age = age;
}
}
public static void main(String[] args) {
Person[] persons = {new Person(“John”, 25), new Person(“Jane”, 30)};
System.out.println(persons[1].age);
}
}
persons[1].name
persons[0].age
persons[1].age
persons[0].name
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
public class Main {
public static void main(String[] args) {
int I = 0;
while (I >= 0) {
System.out.print(I + “ “);
}
}
}
The loop will terminate after one iteration
The loop will run forever.
The loop will run 0 iterations.
It will cause an exception
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
15 questions
CNET151 Chapt 8 Encryption
Quiz
•
University
12 questions
OOP- Class+Object
Quiz
•
University
10 questions
Control Operations and Instruction Sets Quiz
Quiz
•
University
10 questions
TOPIC 1 COMPUTER NETWORK
Quiz
•
University
15 questions
PYTHON UNIT I MCQS
Quiz
•
University
11 questions
Python basics
Quiz
•
University
12 questions
AppsLab_Q3
Quiz
•
1st Grade - Professio...
10 questions
Pengantar Coding
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade