Introduction to Java Applications Input/Output Flashcards
What is a Java application?
A computer program that executes when the java
command launches the Java Virtual Machine (JVM).
What is the Java Virtual Machine (JVM)?
The JVM enables a computer to run Java programs.
What is the purpose of System.out.println("Welcome to Java Programming!");
?
It prints “Welcome to Java Programming!” to the console.
What does public static void main(String[] args)
represent?
It is the main method, the entry point of a Java application.
What are the three types of comments in Java?
-
Single-line comment:
// This is a comment
-
Multi-line comment:
/* This is a multi-line comment */
-
Javadoc comment:
/** This is a Javadoc comment */
How do you declare a Java class?
Using the class
keyword, followed by the class name (e.g., public class Welcome1
).
What is a method in Java?
A method is a block of code that performs a task and may return a value.
What is a syntax error?
A mistake in the code that violates Java’s rules, preventing compilation.
What happens if the filename does not match the public class name?
A compilation error occurs.
What is a variable?
A named storage location in memory that holds a value.
What are Java’s primitive data types?
byte
, short
, int
, long
, float
, double
, char
, boolean
.
How do you declare an integer variable?
int x = 10;
How do you read user input in Java?
Using the Scanner
class (Scanner input = new Scanner(System.in);
).
How do you print output in Java?
Using System.out.print()
, System.out.println()
, or System.out.printf()
.
What does \n
do in Java?
It inserts a newline.