Writing and Running a Java Program Flashcards
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
b) The starting point of program execution
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
b) To print text to the console
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
c) For cosmetic reasons, making the code easier to read
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
b) IntelliJ automatically adds the closing curly brace
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
c) My first Java program
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
b) To mark the end of a command
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
c) They define the text as a string
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
b) In the console
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
b) The program ran successfully without errors
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
c) By selecting ‘Run’ from the Run menu
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
b) The compiled file containing Java bytecode
What process transforms a .java file into a .class file?
a) Debugging
b) Interpreting
c) Compiling
d) Running
c) Compiling
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
c) To show a readable version of the compiled bytecode
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) It converts Java bytecode into machine language
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
c) It is the human-readable source code