lec1 Flashcards

(34 cards)

1
Q

What is a computer program?

A

A set of instructions that tells a computer what to do.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why do computers need programs?

A

Without programs, computers are just empty machines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Java?

A

A popular programming language created in 1995 and owned by Oracle.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Where is Java used?

A

Mobile apps, web apps, desktop apps, games, databases, and more.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why is Java popular?

A

it is platform-independent, secure, fast, and object-oriented.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does “Write Once, Run Anywhere” (WORA) mean?

A

Java code can run on any device with a Java Virtual Machine (JVM).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is source code?

A

The code written by a programmer before it is compiled or interpreted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does an interpreter do?

A

Reads and executes code line by line.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does a compiler do?

A

Translates the entire source code into machine code before execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Does Java use an interpreter or a compiler?

A

Java uses both: the compiler converts code into bytecode, and the JVM interprets it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Where can you download Java?

A

From oracle.com.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are two popular Java IDEs?

A

Eclipse and NetBeans.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What must every Java program have?

A

At least one class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the name of the method where Java starts execution?

A

The main method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the correct syntax for the main method?

A

public static void main(String[] args) { }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does System.out.println(“Hello”); do?

A

Prints “Hello” to the console.

17
Q

How do you write a simple Java program?

A

public class Hello {
public static void main(String[] args) {
System.out.println(“Hello, Java!”);
}
}

18
Q

What is a statement in Java?

A

A command that performs an action, like printing text.

19
Q

Why is documentation important in Java?

A

t makes code easier to understand and maintain.

20
Q

What are good naming conventions for Java?

A

Classes: Start with uppercase (ComputeExpression).
Variables/methods: Start with lowercase (computeSum).

21
Q

How should Java code be formatted?

A

Use indentation and blank lines for readability.

22
Q

What are the three types of errors in Java?

A

Syntax errors – Found by the compiler.
Runtime errors – Cause the program to crash.
Logic errors – Produce incorrect output.

23
Q

What is a runtime error?

A

An error that happens while the program is running.

24
Q

What is an object-oriented language?

A

A language that organizes code using objects and classes.

25
What makes Java secure?
Java runs inside the JVM, which protects the system from harmful code.
26
What is the first step in writing a Java program?
Create a Java class with a main method and write code inside it.
27
What do {} braces do?/What do () parentheses do?
Define a block of code./Enclose method parameters.
28
What do [] brackets do?/ What do // double slashes do?
Define arrays./Create single-line comments.
29
What is a logic error?
A mistake in the program’s logic that gives wrong results.
30
What is a syntax error?
A mistake in code structure, like missing ;.
31
Which of these is a reserved keyword in Java?
class
32
What symbol is used for single-line comments in Java?
//
33
What is the correct way to declare an integer variable in Java?
int number = 10;
34
How do you start a multi-line comment in Java?
/*