Java Basics: Variables and Declarations

DesirableQuantum avatar
DesirableQuantum
·
·
Download

Start Quiz

Study Flashcards

31 Questions

What are the three properties of a variable in Java?

Memory location, data type, name

Which of the following is NOT a Java primitive data type?

String

What is the result of the expression $14 / 4$ in Java?

3

Which operator is used for multiplication in Java?

What is a method in Java?

A set of code which is referred to by name

What are the numeric data types in Java?

Byte, short, int, long, float, double

Which part of a method defines the access type of the method?

Modifier

What is the data type of the value returned by a method with no return value?

void

What is the purpose of a parameter in a method?

Placeholder for passed values

How would you call a method m1 from class A in another class B?

A.m1()

What is used to declare an effectively constant variable in Java?

static final

How are Java constants typically declared?

In ALL CAPS

What symbols are used to indicate comments in Java?

// and /* */

Which characters can be used in Java identifiers?

Letters, digits, underscores (_), and dollar signs ($)

What is the role of an identifier in Java?

To name variables, constants, methods, classes, and packages

Which keyword precedes package identifiers in Java?

package

Which of the following is a correct example of variable initialization in Java?

int x=5;

What is the result of the expression $20 ext{ % }3$ in Java?

2

Which of the following is a Java primitive data type?

Double

In Java, which keyword precedes package identifiers?

package

What is the role of an identifier in Java?

To name a class, method, or variable

What are the three properties of a variable in Java?

Memory location, data type, value

Which of the following is NOT a part of a method in Java?

Parameter Type

What is the role of a static variable declared with the final modifier in Java?

To make the variable globally accessible and unchangeable

How are comments indicated in Java?

By using double slashes (//)

What is the purpose of an identifier in Java?

To name variables, methods, classes, and packages

Which characters are allowed in Java identifiers?

Letters, digits, underscores (_), and dollar signs ($)

What are Java constants typically declared in?

All capital letters

What is the result of the expression $9.0 / 2$ in Java?

$4.5$

Which keyword precedes package identifiers in Java?

packageID

In Java, what does the modifier 'void' indicate for a method?

The method returns no value

Test your knowledge on Java variable declarations and initializations. This quiz covers the basics of storing different types of data in memory locations using variables and their identifiers.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Use Quizgecko on...
Browser
Browser