Home / Community / CS106A - Programming Methodology & Object-Oriented Design (Java)
Public

CS106A - Programming Methodology & Object-Oriented Design (Java)

Master foundational programming and object-oriented design with Java. This comprehensive flashcard deck covers essential CS106A concepts, from basic syntax and control flow to advanced topics like inheritance, polymorphism, and file I/O, preparing you for robust software development.

21 accessible of 21 cards

Card Preview

21 accessible of 21 cards

A quick, read-only look at the deck content.

Term

What is the basic structure of a Java program that can be executed?

Definition

A Java program typically starts execution within the main method, which has the signature public static void main(String[] args) { /* code */ }.

Term

How do you declare and initialize a variable for an integer in Java?

Definition

You declare a variable by specifying its type and name, and initialize it using the assignment operator. For example: int myNumber = 10; declares an integer variable named myNumber and initializes it with the value 10.

Term

Explain the purpose of if-else if-else statements in Java.

Definition

if-else if-else statements are used for conditional execution. The if block executes if its condition is true. If false, the else if conditions are checked sequentially. If all if and else if conditions are false, the else block executes.

Term

What is the primary use of a for loop in Java?

Definition

A for loop is primarily used for iterating a fixed number of times, typically when the number of iterations is known beforehand. It consists of an initialization, a termination condition, and an increment/decrement statement.

Term

How do you define a simple method in Java that takes two integers and returns their sum?

Definition

```java
public int addNumbers(int a, int b) {
return a + b;
}
```

Term

Distinguish between a "class" and an "object" in Java.

Definition

A class is a blueprint or template for creating objects, defining their properties (fields) and behaviors (methods). An object is an instance of a class, a concrete entity created from that blueprint, existing in memory.

Term

What is a constructor in Java and when is it called?

Definition

A constructor is a special method used to initialize new objects of a class. It has the same name as the class and no return type. It's called automatically when an object is created using the new keyword (e.g., MyClass obj = new MyClass();).

Term

Explain the concept of "encapsulation" in OOP and how it's achieved in Java.

Definition

Encapsulation is the bundling of data (instance variables) and methods that operate on the data within a single unit (a class), and restricting direct access to some of an object's components. It's achieved in Java using access modifiers like private for fields and public for "getter" and "setter" methods to control access.

Related Flashcard Sets

Explore similar study materials created by the community

Browse community decks →