Java Intro Flashcards

1
Q

What is Java?

A

A high-level, object-oriented programming language designed for minimal implementation dependencies.

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

What is a key feature of Java that allows it to run on any device?

A

Platform-Independent: Runs on any device with Java Virtual Machine (JVM).

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

What does object-oriented mean in the context of Java?

A

Uses classes and objects to model real-world entities.

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

What is the basic structure of a Java program?

A

Arrangement of components including class declaration, main method, and statements.

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

What is the purpose of ‘public class Main’ in a Java program?

A

Declares the class. Every program must have at least one class.

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

What is the entry point of a Java program?

A

public static void main(String[] args)

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

What does System.out.println() do in Java?

A

Prints text to the console.

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

What is a variable in Java?

A

Stores changeable data during execution.

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

What are primitive data types in Java?

A

Types that define the kind of data, such as:
* int
* double
* char
* boolean

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

What is an example of a reference data type in Java?

A

String: Sequence of characters (e.g., ‘Hello, World!’)

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

What is the difference between declaration and initialization of variables?

A

Declaration specifies the type and name; initialization assigns a value.

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

Fill in the blank: To declare an integer variable in Java, use ______.

A

int x;

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

What are operators in Java?

A

Symbols or keywords used to perform operations on variables/values.

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

List the types of operators in Java.

A
  • Arithmetic Operators
  • Comparison Operators
  • Logical Operators
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the purpose of comments in Java?

A

Non-executable lines for explaining code.

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

What are the two types of comments in Java?

A
  • Single-line: // Comment
  • Multi-line: /* Comment */
17
Q

What is code formatting best practice in Java?

A

Structuring code for readability and consistency.

18
Q

What is recommended for variable names in Java?

A

Camel Case (e.g., myVariable)

19
Q

True or False: Java syntax is strict but logical.

A

True

20
Q

What is the role of variables, data types, and operators in Java?

A

Essential for data manipulation.

21
Q

How does code formatting and commenting affect Java code?

A

Improves readability and maintenance.

22
Q

What is the output of the following code: int a = 10; int b = 20; System.out.println(a + b);?

A

30

23
Q

What does the % operator do in Java?

A

Returns the remainder of division.

24
Q

Fill in the blank: A non-primitive data type in Java is ______.

A

String