Search Header Logo

Quiz on Access Modifiers, Encapsulation, and Class Anatomy

Authored by Lonale Brooks

Computers

9th - 12th Grade

Used 1+ times

Quiz on Access Modifiers, Encapsulation, and Class Anatomy
AI

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

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

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?