stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
OOP Flashcards | StudBud
Explore
/
OOP
OOP
20 terms
·
StudBud Administration
·
26 plays
Imported from external platform
Flashcards
20 cards
F
Practice quiz
P
Host live
L
Questions
20
Answers
1
Which access modifier allows members to be accessed within the same class, subclasses, and classes in the same package?
C. Public
B. Protected
D. Default (Package-Private)
A. Private
2
Which of the following best describes Object-Oriented Programming (OOP)?
A. Focusing on the logic to manipulate data
D. Writing code without using classes
B. Focusing on the objects and how they interact with each other
C. Writing code in a procedural fashion
3
What does encapsulation help achieve in OOP?
A. It makes it easier to inherit properties from other classes
B. It allows for hiding of sensitive data and controlling access to it
D. It creates multiple classes for different objects
C. It abstracts the internal workings of methods
4
What is a subclass in OOP?
A. A class that cannot be inherited
D. A class used to hide implementation details
C. A class created based on an existing class
B. A class that is inherited by another class
5
What is the primary restriction of the private access modifier?
D. Members can be accessed from other classes in the same package
B. Members can be accessed by subclasses
C. Members can be accessed from any class
A. Members are accessible within the same class only
6
access modifier would you use if you want a class member to be accessible only same package not by any external class
C. Protected
B. Public
A. Private
D. Default (Package-Private)
7
What is the effect of using the protected access modifier on a variable in Java?
A. The variable can only be accessed within the class
variable can be accessedbysubclasses,even if they are in different packages
B. The variable can be accessed only by other classes in the same package
D. The variable can be accessed by any class, regardless of the package
8
What happens if no access modifier is specified for a class member in Java?
C. It becomes protected by default
B. It becomes public by default
D. It is package-private (default access)
A. It becomes private by default
9
What is the purpose of polymorphism in OOP?
D. To combine multiple classes into one class
C. To create multiple instances of the same class
B. To hide implementation details from the user
A.Toallow onemethod to behave differently based on the object that calls it
10
Which of the following access modifiers allows members to be accessible from any other class?
B. Protected
D. Default (Package-Private)
A. Private
C. Public
11
Which of the following concepts ensures that data is only accessible through specific methods in OOP?
A. Abstraction
B. Polymorphism
D. Inheritance
C. Encapsulation
12
What is a class in Object-Oriented Programming?
A. An instance of an object
D. A method used to control data access
C. A function to manipulate data
B. A user-defined blueprint for objects
13
In which programming language is the Friend access modifier used to control access to members within the same assembly?
B. C++
A. Java
D. Python
C. Visual Basic
14
Which of the following is an example of inheritance?
B. A Car class with methods for controlling data access
D. Hiding the engine details of a car
A. A Vehicle class with subclasses Car, Bus, and Bicycle
C. A method that behaves differently for each type of object
15
Which access modifier ensures that members are not accessible from other classes, even subclasses?
C. Private
A. Protected
B. Public
D. Default (Package-Private)
16
Which of the following statements about objects in OOP is true?
C. Objects are not related to classes
A. Objects are created using constructors and are instances of a class
B. Objects are only created once and cannot be reused
D. Objects are abstract representations of methods in a class
17
If a class is declared with no access modifier in Java, what will be its accessibility?
C. The class will be accessible only within the package (default access)
B. The class will be public and accessible from any class
D. The class will be protected and accessible only to subclasses
A. The class will be private and inaccessible from outside its package
18
Which access modifier would allow a method in a superclass to be accessed by a subclass, but not by otherclasses outside
B. Protected
C. Public
D. Default (Package-Private)
A. Private
19
What does the private access modifier do in both Java and C++?
C. It allows access only within the class and its package
D. It allows access to class members from subclasses only
A. It allows access to class members from any other class
It restricts accesstothe classmembersfromoutside the class,eveninsubclasses
20
In which situation is the public access modifier generally used?
C. To limit access to the class members only within the same package
D. To allow access only from subclasses
B. To make a class or method accessible by any class in any package
A. To hide sensitive information and allow no external access