Introduction to Java Applications Input/Output Flashcards

1
Q

What is a Java application?

A

A computer program that executes when the java command launches the Java Virtual Machine (JVM).

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

What is the Java Virtual Machine (JVM)?

A

The JVM enables a computer to run Java programs.

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

What is the purpose of System.out.println("Welcome to Java Programming!");?

A

It prints “Welcome to Java Programming!” to the console.

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

What does public static void main(String[] args) represent?

A

It is the main method, the entry point of a Java application.

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

What are the three types of comments in Java?

A
  1. Single-line comment: // This is a comment
  2. Multi-line comment: /* This is a multi-line comment */
  3. Javadoc comment: /** This is a Javadoc comment */
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you declare a Java class?

A

Using the class keyword, followed by the class name (e.g., public class Welcome1).

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

What is a method in Java?

A

A method is a block of code that performs a task and may return a value.

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

What is a syntax error?

A

A mistake in the code that violates Java’s rules, preventing compilation.

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

What happens if the filename does not match the public class name?

A

A compilation error occurs.

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

What is a variable?

A

A named storage location in memory that holds a value.

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

What are Java’s primitive data types?

A

byte, short, int, long, float, double, char, boolean.

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

How do you declare an integer variable?

A

int x = 10;

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

How do you read user input in Java?

A

Using the Scanner class (Scanner input = new Scanner(System.in);).

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

How do you print output in Java?

A

Using System.out.print(), System.out.println(), or System.out.printf().

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

What does \n do in Java?

A

It inserts a newline.

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

What does \t do in Java?

A

It inserts a tab space.

17
Q

What is an if statement used for?

A

To execute code based on a condition.

18
Q

What are Java’s relational operators?

A

>, <, >=, <=.

19
Q

What are Java’s equality operators?

A

== (equal) and != (not equal).

20
Q

How do you compile a Java program?

A

By using the command javac FileName.java.

21
Q

How do you execute a compiled Java program?

A

By using the command java FileName (without .class).

22
Q

What is the difference between print and println?

A

print does not move to a new line after printing, while println does.