Writing and Running a Java Program Flashcards

1
Q

What does the main function in Java represent?

a) The declaration of a variable
b) The starting point of program execution
c) The initialization of a class
d) The end of the program

A

b) The starting point of program execution

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

What is the purpose of the System.out.println method?

a) To initialize variables
b) To print text to the console
c) To define the main function
d) To handle exceptions

A

b) To print text to the console

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

Why is indentation used in Java?

a) To improve the program’s performance
b) To ensure the code runs correctly
c) For cosmetic reasons, making the code easier to read
d) To signal the end of the program

A

c) For cosmetic reasons, making the code easier to read

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

What happens when you hit Enter after typing the opening curly brace in IntelliJ?

a) IntelliJ highlights the code for errors
b) IntelliJ automatically adds the closing curly brace
c) The program is saved automatically
d) The class is renamed

A

b) IntelliJ automatically adds the closing curly brace

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

What text will be printed to the console when the following line is executed?
System.out.println("My first Java program");

a) My first program
b) Java program
c) My first Java program
d) No text will be printed

A

c) My first Java program

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

What is the purpose of the semicolon at the end of a command in Java?

a) To start a new block of code
b) To mark the end of a command
c) To indicate an error
d) To insert a comment

A

b) To mark the end of a command

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

What is the significance of the double quotes in System.out.println("My first Java program");?

a) They indicate the start and end of a class name
b) They mark a variable
c) They define the text as a string
d) They are used to end the line of code

A

c) They define the text as a string

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

Where can you find the output of the Java program in IntelliJ?

a) In the source code file
b) In the console
c) In the toolbar
d) In the file menu

A

b) In the console

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

What does the exit code 0 indicate after running the program?

a) The program finished with errors
b) The program ran successfully without errors
c) The program needs to be compiled again
d) The program was saved automatically

A

b) The program ran successfully without errors

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

What is one of the ways to run a Java program in IntelliJ?

a) By typing ‘Run’ in the console
b) By selecting ‘Build’ from the menu
c) By selecting ‘Run’ from the Run menu
d) By renaming the program file

A

c) By selecting ‘Run’ from the Run menu

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

What does the .class file represent in the Project pane of IntelliJ?

a) The source file written by the programmer
b) The compiled file containing Java bytecode
c) A configuration file for IntelliJ
d) The output of the program

A

b) The compiled file containing Java bytecode

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

What process transforms a .java file into a .class file?

a) Debugging
b) Interpreting
c) Compiling
d) Running

A

c) Compiling

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

Why does IntelliJ display a decompiled version of the .class file?

a) To allow editing of the bytecode
b) To display an executable form of the program
c) To show a readable version of the compiled bytecode
d) To show the source file in a different format

A

c) To show a readable version of the compiled bytecode

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

What role does the Java Virtual Machine (JVM) play in executing a Java program?

a) It converts Java bytecode into machine language
b) It writes Java code
c) It decompiles .class files into .java files
d) It compiles source files

A

a) It converts Java bytecode into machine language

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

What is the significance of the .java source file in a Java program?

a) It contains machine language
b) It contains the compiled bytecode
c) It is the human-readable source code
d) It is the configuration for the project

A

c) It is the human-readable source code

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