AP CSA writing classes key terms

Essential key terms and concepts for AP Computer Science A related to writing classes.

NoraW0·20 fiszki·10 pytania
APcomputer_scienceprogramming
0
Umiem
1 / 20
0
Uczę się
Przód

What is a class?

Kliknij, aby odwrócić
Tył

A blueprint for creating objects containing methods and attributes.

Kliknij, aby odwrócić
Umiem
Uczę się

Quiz(10 pytania)

Pytanie 1 z 10

1. What concept allows classes to derive properties from other classes?

Pojęcia w tym zestawie(20)

What is a class?

A blueprint for creating objects containing methods and attributes.

What is an object?

An instance of a class that can hold data and methods.

Difference between class and object

A class is a template; an object is a specific instance of that template.

What are attributes?

Variables that hold data specific to a class or object.

What are methods?

Functions defined within a class that can perform actions on its objects.

True or false: A class can have multiple objects.

True, because many instances can be created from a single class.

What is encapsulation?

Restricting access to certain components of an object.

Fill in the blank: Encapsulation improves _____ and reusability.

modularity.

What is inheritance?

The mechanism by which one class can inherit fields and methods from another.

Difference between inheritance and composition

Inheritance creates a parent-child relationship; composition builds a has-a relationship.

What is polymorphism?

The ability to present the same interface for different underlying data types.

True or false: Polymorphism can occur through method overloading.

True, because it allows different methods to share the same name.

What is a constructor?

A special method used to initialize objects of a class.

What does 'this' refer to?

The current object instance within instance methods.

What is method overloading?

Defining multiple methods with the same name but different parameters.

What is a static method?

A method that belongs to the class, rather than instances of the class.

True or false: All methods in a class must be static.

False, because instance methods are also essential.

What does 'interface' define?

A contract that classes can implement, defining methods without implementation.

What is abstraction?

Hiding complex implementation details and exposing only necessary features.

True or false: A class can implement multiple interfaces.

True, allowing for greater flexibility in design.

Pytania w tym zestawie(10)

1. What concept allows classes to derive properties from other classes?

A.A. Encapsulation
B.B. Inheritance
C.C. Abstraction
D.D. Polymorphism

2. Which of the following is NOT a characteristic of an object?

A.A. State
B.B. Behavior
C.C. Class name
D.D. Identity

3. What does encapsulation primarily achieve?

A.A. Code reuse
B.B. Data hiding
C.C. Method overloading
D.D. Inheritance

4. Which method type is invoked without creating an instance of a class?

A.A. Instance method
B.B. Constructor
C.C. Static method
D.D. Abstract method

5. What is the purpose of a constructor in a class?

A.A. To destroy objects
B.B. To initialize objects
C.C. To define methods
D.D. To inherit properties

6. Which is an example of method overloading?

A.A. Same method name, same parameters
B.B. Same method name, different parameters
C.C. Different method names, same functionality
D.D. Same method name, different return types

7. True or false: An interface can contain method implementations.

A.A. True
B.B. False
C.C. Only if it's abstract
D.D. Only in Java 8+

8. What does the 'this' keyword refer to in a method?

A.A. The previous object
B.B. The calling class
C.C. The current instance
D.D. The parent class

9. When is polymorphism typically utilized?

A.A. Method overloading
B.B. Inheritance only
C.C. Method overriding
D.D. Both A and C

10. Fill in the blank: A class is a blueprint for creating _____ .

A.A. Arrays
B.B. Methods
C.C. Objects
D.D. Interfaces

Powiązane zestawy

Stwórz własny zestaw

Wgraj PDF, wklej notatki lub opisz temat – AI wygeneruje fiszki, quizy i więcej w kilka sekund.