Java syntax

Java syntax

Assessment

Flashcard

Computers

University

Easy

Created by

Prof Yetty

Used 5+ times

FREE Resource

Student preview

quiz-placeholder

59 questions

Show all answers

1.

FLASHCARD QUESTION

Front

What is the correct file extension for a Java program? Options: .java, .js, .py, .txt

Back

.java

Answer explanation

Java files are saved with a .java extension.

2.

FLASHCARD QUESTION

Front

Which keyword is used to declare a variable? Options: variable, var, int, let

Back

int

Answer explanation

In Java, 'int' is used for integer variables.

3.

FLASHCARD QUESTION

Front

What does the 'public' keyword signify in Java?

Back

It is accessible to all

Answer explanation

public' allows access from any class in the program.

4.

FLASHCARD QUESTION

Front

How do you print text to the console in Java?

Back

System.out.println()

Answer explanation

System.out.println() is the correct way to print to the console in Java.

5.

FLASHCARD QUESTION

Front

What happens if a local int variable is used without initialization?

Back

It is initialized to 0.

Answer explanation

"Local variables in Java must be explicitly initialized before use, as they do not have default values. Attempting to use an uninitialized local variable results in a compilation error.

6.

FLASHCARD QUESTION

Front

What symbol is used to end a Java statement?

Back

;

Answer explanation

Java statements end with a semicolon (;).

7.

FLASHCARD QUESTION

Front

What is the correct syntax for a single-line comment?

Back

//

Answer explanation

Single-line comments in Java start with //.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?