NEW
Font size
WorksheetsBSAIT 1-2 QUIZ
Total questions: 20
Worksheet time: 10mins
What is a variable in Java?
A constant value
A named memory location that can store a value
A method to execute code
A type of data structure
Which keyword is used to declare a named constant in Java?
static
final
const
immutable
What does the main() method signify in a Java program?
The end of the program
The starting point for execution
A method for input
A method for output
Which of the following is a primitive data type in Java?
String
Array
int
List
What symbol is used to start a single-line comment in Java?
/* */
//
#
//* *//
Which of the following is NOT a valid way to declare a variable in Java?
int a = 5;
float b = 2.5f;
char c = 'A';
string d = "Hello";
Which of the following data types can hold decimal values?
int
char
float
boolean
Which of the following statements about comments in Java is true?
Comments are ignored by the compiler
Comments must be written in uppercase
Comments can affect the execution of the program
omments are mandatory in every Java program
What is the correct way to declare a variable of type double in Java?
double d = 5.0;
double d = 5;
double d = "5.0";
Doublr d = 5.0
What is the correct way to declare a variable of type int in Java?
int a = 4.5;
int A = 4.0;
Int a = 5;
int a = 7;
double Double = 78.5;
True
False
char Char = B;
True
False
boolean Boolean = True;
True
False
String string = "Romeo";
True
False
float Float = 45.6;
True
False
byte Grade = 129;
True
False
short Short = 33000;
True
False
double Boolean = 46.78;
True
False
int Char = 67;
True
False
double Float = 90.0;
True
False
