AP CSA using objects key terms

Essential key terms and concepts for AP Computer Science A focusing on object-oriented programming.

Noah2009·27 schede·20 domande
APcomputer_scienceprogramming
0
Lo so
1 / 27
0
Sto imparando
Fronte

What is an object?

Tocca per girare
Retro

An instance of a class that contains both data and methods.

Tocca per girare
Lo so
Sto imparando

Quiz(20 domande)

Domanda 1 di 20

1. What is the purpose of encapsulation in OOP?

Termini in questo set(27)

What is an object?

An instance of a class that contains both data and methods.

What is a class?

A blueprint for creating objects, defining properties and behaviors.

True or false: All objects belong to a class.

True, because a class defines the structure for creating objects.

Difference between method and constructor.

A method performs actions, a constructor initializes new objects.

What is encapsulation?

The bundling of data with methods that operate on that data, restricting access.

What does 'inheritance' mean?

A mechanism where a new class can inherit properties from an existing class.

Fill in the blank: A __________ is a method that calls itself.

recursive method

What is polymorphism?

The ability to process objects differently based on their data type or class.

What is an interface?

A contract that specifies methods a class must implement without defining them.

True or false: A class cannot implement multiple interfaces.

False, because a class can implement multiple interfaces in Java.

What does 'overloading' mean?

Defining multiple methods with the same name but different parameters.

What is abstraction?

The concept of hiding complex implementation details and showing only essentials.

Difference between static and instance methods.

Static methods belong to the class; instance methods belong to the object.

Fill in the blank: The __________ keyword is used to create a new object in Java.

new

What is a constructor?

A special method that initializes new objects of a class.

What is method overriding?

When a subclass provides a specific implementation of a method already defined in its superclass.

True or false: An abstract class cannot be instantiated.

True, because it contains abstract methods that must be implemented.

What does 'this' refer to in a method?

The current object instance in which the method is being invoked.

Fill in the blank: A __________ variable is shared among all instances of a class.

static

What is a package?

A namespace that organizes a set of related classes and interfaces.

Difference between public and private access modifiers.

Public members are accessible from anywhere; private members are only accessible within the class.

What is a getter?

A method that retrieves the value of a class property.

What is a setter?

A method that sets or updates the value of a class property.

Fill in the blank: An __________ is a special type of method used to initialize an object.

initializer

What is the main purpose of constructors?

To set initial values for object attributes when an object is created.

What does 'final' keyword do?

Used to declare constants or prevent method overriding and inheritance.

What is a software library?

A collection of pre-written code that developers can use to optimize tasks.

Domande in questo set(20)

1. What is the purpose of encapsulation in OOP?

A.To restrict access to class members
B.To allow multiple inheritance
C.To create new objects
D.To define a class

2. Which keyword is used to create a new object in Java?

A.create
B.instantiate
C.new
D.object

3. Which of the following is NOT a benefit of using inheritance?

A.Code reusability
B.Method overriding
C.Data hiding
D.Increased complexity

4. What is method overloading?

A.Same name, different return type
B.Same name, different parameters
C.Different names, same parameters
D.Same name, same parameters

5. Which access modifier allows visibility across all classes?

A.private
B.protected
C.public
D.default

6. Which defines a class that cannot be instantiated?

A.Abstract class
B.Final class
C.Concrete class
D.Static class

7. What is the role of a constructor in Java?

A.To define the class
B.To create methods
C.To initialize object state
D.To destroy objects

8. Which is true about static methods?

A.Can access instance variables
B.Belong to the class, not instances
C.Can be overridden
D.Cannot be inherited

9. Which of the following is an example of polymorphism?

A.Same method name with different parameters
B.Accessing a method in a superclass
C.Overriding a method in a subclass
D.All of the above

10. What does the 'super' keyword do?

A.Refers to the superclass
B.Creates a new instance
C.Hides a variable
D.Calls a static method

11. What is an interface primarily used for?

A.To create abstract classes
B.To define methods without implementations
C.To implement multiple inheritance
D.To create packages

12. Which statement about getters and setters is true?

A.They are used to access private data
B.They must be public
C.They can be static
D.They must return void

13. What happens when you declare a variable as 'final'?

A.It can be changed later
B.It cannot be overridden
C.It cannot be modified after initialization
D.It is static

14. Which of the following correctly describes a concrete class?

A.Cannot be instantiated
B.Can be instantiated
C.Contains only abstract methods
D.Is a subclass only

15. What does the phrase 'data hiding' refer to?

A.Accessing data directly
B.Using private variables
C.Encapsulation of methods
D.Public access of properties

16. What is the main purpose of using classes in programming?

A.To create functions
B.To encapsulate data and methods
C.To increase performance
D.To define variables

17. True or false: A method can return multiple values.

A.True
B.False
C.Depends on the method
D.Only with arrays

18. What does 'dynamic binding' refer to?

A.Determining method calls at runtime
B.Class loading
C.Memory allocation
D.Static method resolution

19. Which keyword prevents a method from being overridden?

A.final
B.private
C.static
D.abstract

20. What is the significance of the 'this' keyword?

A.Refers to the class
B.Refers to the object itself
C.Used for static methods
D.It is a default parameter

Set correlati

Crea il tuo set di studio

Carica un PDF, incolla le tue note o descrivi un argomento – l'IA genera schede, quiz e altro in pochi secondi.