
Quiz on Access Modifiers, Encapsulation, and Class Anatomy

Quiz
•
Computers
•
9th - 12th Grade
•
Easy
Lonale Brooks
Used 1+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the primary purpose of access modifiers?
To simplify the syntax of the language
To increase the size of the code
To control the visibility of classes, methods, and variables
To enhance the speed of the program
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which access modifier allows a method to be accessed from any other class?
Private
Protected
Public
Default
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the role of constructors in a class?
To execute the main method
To compile the code
To initialize instance variables
To destroy objects
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a non-void method?
public void accelerate(int increment)
public int getSpeed()
public void stop()
public void setSpeed(int speed)
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the scope of a static variable?
Class-wide scope
Limited to the method it is defined in
Limited to the package
Limited to the instance of the class
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is encapsulation in object-oriented programming?
A method to increase the speed of execution
A principle to hide the internal state and require all interaction to be performed through an object's methods
A way to write more code
A technique to reduce the size of the program
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a characteristic of void methods?
They do not perform any action
They return a value
They are used to initialize instance variables
They perform actions but do not return a value
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
Object Orientation 2

Quiz
•
11th Grade
12 questions
week 1 basic java coding language

Quiz
•
9th - 12th Grade
12 questions
AppsLab_Q3

Quiz
•
1st Grade - Professio...
11 questions
Python functions

Quiz
•
12th Grade
10 questions
Object-Oriented Programming (OOP) in Python 3 Quiz

Quiz
•
12th Grade
15 questions
Java Test 1

Quiz
•
10th Grade
10 questions
OOP

Quiz
•
9th - 12th Grade
15 questions
Introduction to Java

Quiz
•
10th Grade
Popular Resources on Wayground
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
20 questions
PBIS-HGMS

Quiz
•
6th - 8th Grade
10 questions
"LAST STOP ON MARKET STREET" Vocabulary Quiz

Quiz
•
3rd Grade
19 questions
Fractions to Decimals and Decimals to Fractions

Quiz
•
6th Grade
16 questions
Logic and Venn Diagrams

Quiz
•
12th Grade
15 questions
Compare and Order Decimals

Quiz
•
4th - 5th Grade
20 questions
Simplifying Fractions

Quiz
•
6th Grade
20 questions
Multiplication facts 1-12

Quiz
•
2nd - 3rd Grade