The Oops moment/2

Quiz
•
Engineering
•
University
•
Hard
Mekha S R
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What does the new keyword do in Java?
Deletes an object
Copies an object
Creates a new object
Imports a class
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following is a correct way to define an enum?
enum Color = {Red, Green, Blue}
enum Color {Red, Green, Blue}
Color enum {Red, Green, Blue}
enum(Color) => Red, Green, Blue
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How do you access a private variable from outside the class?
Use public keyword
Use a getter or setter method
Make it static
Use a constructor
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which method returns a string representation of an object?
show()
print()
toString()
getInfo()
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What does a constructor do in a class?
Creates variables
Destroys objects
Initializes new objects
Runs loops
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Why are getter and setter methods commonly used in Java classes?
To repeatedly execute blocks of code within loops defined in the class
To safely retrieve and modify the values of private fields while maintaining encapsulation
To automatically delete unused variables when the object is destroyed
To bypass access modifiers and make all fields globally accessible
7.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
enum Size { SMALL, MEDIUM, LARGE }
public class Test {
public static void main(String[] args) {
Size s = Size.LARGE;
System.out.println(s);
}
}
SMALL
Size
LARGE
null
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
Monday Warm Up Newton's Laws

Quiz
•
9th Grade - University
10 questions
OOP_1

Quiz
•
University
10 questions
C Programming Day-10

Quiz
•
University
10 questions
Computer Science Workshop Quiz

Quiz
•
University
10 questions
Understanding Java and SQL Concepts

Quiz
•
University
10 questions
Pre Test P2_Diode Applications

Quiz
•
University
15 questions
Servlet Wipro

Quiz
•
University
15 questions
14/1 Newton's Laws of Motion

Quiz
•
12th Grade - University
Popular Resources on Wayground
12 questions
Unit Zero lesson 2 cafeteria

Lesson
•
9th - 12th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
20 questions
Lab Safety and Equipment

Quiz
•
8th Grade
13 questions
25-26 Behavior Expectations Matrix

Quiz
•
9th - 12th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Engineering
15 questions
Let's Take a Poll...

Quiz
•
9th Grade - University
2 questions
Pronouncing Names Correctly

Quiz
•
University
12 questions
Civil War

Quiz
•
8th Grade - University
18 questions
Parent Functions

Quiz
•
9th Grade - University
21 questions
Mapa países hispanohablantes

Quiz
•
1st Grade - University
19 questions
Primary v. Secondary Sources

Quiz
•
6th Grade - University
25 questions
Identifying Parts of Speech

Quiz
•
8th Grade - University
20 questions
Disney Trivia

Quiz
•
University