
java quiz
Quiz
•
Computers
•
University
•
Hard
Giri A
Used 3+ times
FREE Resource
Enhance your content
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
Create a free account and access millions of resources
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
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?
Similar Resources on Wayground
10 questions
Session 2
Quiz
•
University
10 questions
Q3 G9/10 Quiz on Site Development Plan M8
Quiz
•
9th Grade - University
15 questions
EDA PARTE 2
Quiz
•
University
10 questions
Data Analytics using Python - Quiz 1
Quiz
•
University
10 questions
Prob. prog 4.
Quiz
•
University
11 questions
Quiz 1
Quiz
•
University
10 questions
C Programming Quiz-5
Quiz
•
University
10 questions
java quiz on Encapsulation and Abstraction
Quiz
•
University
Popular Resources on Wayground
20 questions
Brand Labels
Quiz
•
5th - 12th Grade
11 questions
NEASC Extended Advisory
Lesson
•
9th - 12th Grade
10 questions
Ice Breaker Trivia: Food from Around the World
Quiz
•
3rd - 12th Grade
10 questions
Boomer ⚡ Zoomer - Holiday Movies
Quiz
•
KG - University
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
Adding Integers
Quiz
•
6th Grade
10 questions
Multiplication and Division Unknowns
Quiz
•
3rd Grade
20 questions
Multiplying and Dividing Integers
Quiz
•
7th Grade
Discover more resources for Computers
10 questions
Boomer ⚡ Zoomer - Holiday Movies
Quiz
•
KG - University
22 questions
FYS 2024 Midterm Review
Quiz
•
University
20 questions
Physical or Chemical Change/Phases
Quiz
•
8th Grade - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)
Quiz
•
8th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
12 questions
1 Times Tables
Quiz
•
KG - University
20 questions
Disney Trivia
Quiz
•
University
38 questions
Unit 6 Key Terms
Quiz
•
11th Grade - University