zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcard
Study GuideStudy GuideQuestion BankQuestion BankGlossaryGlossary

What are the differences between static and dynamic method dispatch?

Static dispatch: Determined at compile time, faster. Dynamic dispatch: Determined at runtime, more flexible.

Flip to see [answer/question]
Flip to see [answer/question]
Revise later
SpaceTo flip
If confident

All Flashcards

What are the differences between static and dynamic method dispatch?

Static dispatch: Determined at compile time, faster. Dynamic dispatch: Determined at runtime, more flexible.

What are the differences between method overloading and method overriding?

Overloading: Multiple methods with the same name but different parameters in the same class. Overriding: A method in a subclass with the same name and parameters as a method in its superclass.

What is the difference between inheritance and polymorphism?

Inheritance: Mechanism for code reuse and creating 'is-a' relationships. Polymorphism: Ability of an object to take on many forms, often achieved through inheritance.

What is the difference between an abstract class and an interface?

Abstract Class: Can have concrete methods and instance variables. Interface: Can only have abstract methods and constants (until Java 8).

What are the differences between early and late binding?

Early Binding: Method call is resolved at compile time. Late Binding: Method call is resolved at runtime.

What are the differences between compile-time and runtime errors?

Compile-time errors: Detected during compilation. Runtime errors: Occur during program execution.

What is the difference between a class and an object?

Class: Blueprint for creating objects. Object: Instance of a class.

What is the difference between a local variable and an instance variable?

Local variable: Declared inside a method. Instance variable: Declared inside a class but outside any method.

What are the differences between procedural and object-oriented programming?

Procedural: Focuses on procedures/functions. Object-oriented: Focuses on objects and their interactions.

What is the difference between composition and inheritance?

Composition: 'Has-a' relationship, objects contain other objects. Inheritance: 'Is-a' relationship, classes inherit from other classes.

What is the definition of static type?

The type a variable is declared as.

What is the definition of dynamic type?

The type of the constructor call when an object is created.

What is method overriding?

Redefining a method in a subclass that is already defined in its superclass.

What is a superclass?

A class from which other classes inherit.

What is a subclass?

A class that inherits from another class (superclass).

What is static method?

A method that belongs to the class itself rather than to any specific instance.

What is non-static method?

A method that requires an object of its class to be called.

What is inheritance?

A mechanism where a new class inherits properties and behaviors from an existing class.

What is polymorphism?

The ability of an object to take on many forms.

What is the difference between static and dynamic binding?

Static binding is resolved at compile time, dynamic at runtime.

What is the significance of static type in method calling?

Determines which method is called for static methods.

What is the significance of dynamic type in method calling?

Determines which method is called for non-static methods.

How does inheritance relate to polymorphism?

Inheritance allows subclasses to be treated as instances of their superclass, enabling polymorphism.

Explain the concept of method overriding in polymorphism.

Subclasses provide specific implementations of methods already defined in their superclass, allowing different behavior for the same method call.

Why is understanding static and dynamic types important for polymorphism?

It clarifies which version of a method will be executed at runtime, especially in inheritance hierarchies.

Explain the difference between compile-time and runtime polymorphism.

Compile-time polymorphism (static binding) is resolved during compilation, while runtime polymorphism (dynamic binding) is resolved during execution.

What is the role of the @Override annotation?

It indicates that a method is overriding a method in the superclass and helps prevent errors.

What is the Liskov Substitution Principle?

Subtypes must be substitutable for their base types without altering the correctness of the program.

How does polymorphism increase code flexibility?

Allows writing code that can work with objects of different classes in a uniform way.

Explain the concept of 'is-a' relationship in inheritance.

A subclass 'is-a' type of its superclass, meaning it inherits its properties and behaviors.