Quiz on Access Modifiers, Encapsulation, and Class Anatomy

Quiz on Access Modifiers, Encapsulation, and Class Anatomy

9th - 12th Grade

10 Qs

quiz-placeholder

Similar activities

QUIZ-I-OBJECT ORIENTED PROGRAMMING WITH C++

QUIZ-I-OBJECT ORIENTED PROGRAMMING WITH C++

10th Grade - University

10 Qs

Java Scope mini quiz

Java Scope mini quiz

9th - 12th Grade

9 Qs

user defined methods in java

user defined methods in java

10th Grade

13 Qs

Object Oriented Programming in Python

Object Oriented Programming in Python

5th - 12th Grade

11 Qs

CS1 Unit 5

CS1 Unit 5

9th - 12th Grade

15 Qs

AP Computer Science A Unit 5

AP Computer Science A Unit 5

9th - 12th Grade

15 Qs

Week 8

Week 8

12th Grade

13 Qs

Object Oriented Programming

Object Oriented Programming

11th Grade

9 Qs

Quiz on Access Modifiers, Encapsulation, and Class Anatomy

Quiz on Access Modifiers, Encapsulation, and Class Anatomy

Assessment

Quiz

Computers

9th - 12th Grade

Easy

Created by

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?