Home / Community / Monash FIT2093 - Introduction to Programming (Java Fundamentals)
Public

Monash FIT2093 - Introduction to Programming (Java Fundamentals)

Master Java fundamentals for Monash FIT2093 with this high-yield flashcard deck! Dive into core programming concepts, OOP principles, control structures, and essential Java syntax to ace your introductory university course.

22 accessible of 22 cards

Card Preview

22 accessible of 22 cards

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

Term

What is the basic structure of a Java program's main method?

Definition

The entry point for any Java application is the main method, defined as:
```java
public static void main(String[] args) {
// Program logic goes here
}
```

Term

Differentiate between single-line and multi-line comments in Java.

Definition

Single-line comments start with //. Example: // This is a comment
Multi-line comments start with /* and end with */. Example: /* This is a multi-line comment */

Term

List the four main primitive data types in Java for storing whole numbers, decimal numbers, single characters, and boolean values.

Definition

1. int: For whole numbers (e.g., 10, -5).
2. double: For floating-point numbers (e.g., 3.14, -0.5).
3. char: For single characters (e.g., 'A', 'z').
4. boolean: For true/false values.

Term

How do you declare and initialize an int variable named age with the value 30 in Java?

Definition

int age = 30;

Term

Explain the purpose of type casting in Java and provide an example of explicit casting.

Definition

Type casting converts a value from one data type to another.
  • Implicit (widening): Automatic conversion from a smaller to a larger type (e.g., int to double).
  • Explicit (narrowing): Manual conversion from a larger to a smaller type, which might result in data loss.
Example: double myDouble = 9.78; int myInt = (int) myDouble; // myInt will be 9

Term

What are the three main categories of operators used for comparison, logic, and arithmetic in Java?

Definition

  • Relational Operators: == (equal to), != (not equal to), < (less than), > (greater than), <= (less than or equal to), >= (greater than or equal to).
  • Logical Operators: && (logical AND), || (logical OR), ! (logical NOT).
  • Arithmetic Operators: +, -, *, /, % (modulo).

Term

Write a simple if-else statement that checks if a variable score is greater than or equal to 50 and prints "Pass" or "Fail" accordingly.

Definition

```java
int score = 65;
if (score >= 50) {
System.out.println("Pass");
} else {
System.out.println("Fail");
}
```

Term

Describe the difference between a while loop and a do-while loop.

Definition

A while loop checks its condition before executing the loop body. If the condition is initially false, the body never executes.
A do-while loop executes its body at least once before checking its condition. The condition is checked after the first iteration.