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

What are the steps to execute an 'if' statement?

  1. Evaluate the condition. 2. If true, execute the code block. 3. If false, skip the code block.
Flip to see [answer/question]
Flip to see [answer/question]
Revise later
SpaceTo flip
If confident

All Flashcards

What are the steps to execute an 'if' statement?

  1. Evaluate the condition. 2. If true, execute the code block. 3. If false, skip the code block.

What are the steps to execute a 'for' loop?

  1. Initialize the loop variable. 2. Check the condition. 3. If true, execute the loop body. 4. Increment/decrement the loop variable. 5. Repeat steps 2-4 until the condition is false.

What are the steps to execute a 'while' loop?

  1. Check the condition. 2. If true, execute the loop body. 3. Update the loop variable (if necessary). 4. Repeat steps 1-3 until the condition is false.

What are the steps to create an object from a class?

  1. Declare a variable of the class type. 2. Use the 'new' keyword followed by the class name and parentheses. 3. Optionally, initialize the object's fields.

What is a conditional statement?

A statement that executes code based on a true/false condition.

What is an 'if' statement?

A one-way selection statement that executes code if a condition is true.

What is a 'for' loop?

A loop that repeats a block of code a specific number of times.

What is a 'while' loop?

A loop that repeats a block of code until a condition is false.

What is a String?

A sequence of characters; an object in Java.

What is an Array?

A data structure that stores multiple values of the same type.

What is a Class?

A blueprint for creating objects; defines data and behavior.

What is an Object?

An instance of a class.

What is Inheritance?

A mechanism where a class inherits properties and methods from another class.

What is Polymorphism?

The ability of objects of different classes to be treated as objects of a common type.

How are conditional statements applied in real-world scenarios?

Controlling traffic lights, validating user input, decision-making in games.

How are loops applied in real-world scenarios?

Iterating through data in a database, repeating actions in a game, processing elements in an array.

How are Strings applied in real-world scenarios?

Storing and manipulating text data, processing user input, representing names and addresses.

How are Arrays applied in real-world scenarios?

Storing lists of items, representing game boards, managing collections of data.

How are Classes and Objects applied in real-world scenarios?

Modeling real-world entities (e.g., cars, people, bank accounts) in software.

How is Inheritance and Polymorphism applied in real-world scenarios?

Creating a hierarchy of animal classes where each animal makes a different sound, but all are treated as animals.