WorksheetsT&P Java Test-1
Total questions: 60
Worksheet time: 30mins
Is this a valid statement and why?
long i = 1;
double d = i + 1;
Yes, the compiler casts automatically
No, the cast needs to happen manually
Yes, because range of int is smaller then the range of double
No, double has a smaller range than int
_________ data type is used to store 'true' or 'false' value
boolean
int
float
char
size of double data type is ______________
8 bits
32 bits
16 bits
64 bits
Which of the following is NOT a primitive datatype?
byte
boolean
String
int
Which of these is necessary condition for automatic type conversion in Java?
The destination type is smaller than source type
The destination type is larger than source type
The destination type can be larger or smaller than source type
None of the mentioned
What will be the error in the following Java code?
byte b = 50;
b = b * 50;
b cannot contain value 100, limited by its range
* operator has converted b * 50 into int, which can not be converted to byte without casting
b cannot contain value 50
No error in this code
If an expression contains double, int, float, long, then the whole expression will be promoted into which of these data types?
long
int
double
float
Can 8 byte long data type be automatically type cast to 4 byte float data type?
True
False
Java is a
Procedure Oriented Language
Structure Oriented Language
Object_Oriented Language
Machine Language
Java is a
Procedure Oriented Language
Structure Oriented Language
Object_Oriented Language
Machine Language
The name of the following should be the file name in Java
Object Name
Variable Nam
Class Name
Array Name
Java program is
Interpreted
Compiled
Java program does not run without below function
user()
system()
main()
void()
A ___________ file is created after successful compilation of a Java program.
Object file
Array file
Class file
String file
Command to compile Java program
javax
javay
javac
Java
Command to run a Java program
javaa
java
jaava
jaavaa
JDK stands for
Java Developer Kit
Java Development Kit
Java Design Kit
Java Debugging Kit
JRE stands for
Java Run Environment
Java Run Execution
Java Runtime Environment
Java Ready Execution
Java is
Machine dependent language
Machine independent language
Java program does not run without below function
user()
system()
main()
void()
Which of the following is incorrect?
int count = 50.0;
int salary = 50_000;
int salary = 50_00;
all of these are incorrect
Determine whether the following identifier is true/false.
int _$c;
True
False
Determine whether the following identifier is true/false.
int 2_w;
True
False
Determine whether the following identifier is true/false.
int .f;
True
False
Determine whether the following identifier is true/false.
int -d;
True
False
Determine whether the following identifier is true/false.
int _$;
True
False
Determine whether the following identifier is true/false.
int this_is_a_detailed_name_for_identifier;
True
False
Determine whether the following identifier is true/false.
int :b;
True
False
Determine whether the following identifier is true/false.
int e#;
True
False
Determine whether the following identifier is true/false.
int 7g;
True
False
Determine whether the following identifier is true/false.
int _a;
True
False
Which of the following is a valid Java keyword?
var
123switch
_if
public
Choose the invalid variable name in Java.
myVariable
$variable
_variableName
123variable
Identify the invalid variable name in Java.
myVariable
$variable
_variable Name
variable123
Identify the invalid variable name in Java.
myVariable
*variable
_variableName
variable123
Which of the following is a valid Java keyword?
var
123switch
_if
public
What is the correct rule for identifiers in Java?
Identifiers can start with a number
Identifiers can contain special characters like @, #, and %
Identifiers are case-insensitive
Identifiers cannot be a keyword
Which of the following is a valid variable name in Java?
123variable
_variable
variable$
variable_name
What is the correct rule for identifiers in Java?
Identifiers can start with a number
Identifiers can contain special characters like @, #, and %
Identifiers are case-insensitive
Identifiers cannot be a keyword
What is the correct rule for identifiers in Java?
Identifiers can start with a special character
Identifiers can have spaces in between
Identifiers cannot be a reserved keyword
Identifiers can be of any length
Which of the following is a valid variable name in Java?
123variable
_variable
variable$
variable_name
Which of the following is the correct main() method signature in Java?
public static void main (String [] args)
public static void Main (String [] args)
public static void main (string [] args)
public static void main (String args)
Which of the following is a valid variable declaration in Java?
int 1myInteger = 0;
int int = 0;
Int my Integer = 0;
int myInteger = 0;
Which of the following is a reserved word in Java?
export
import
input
output
Which of this command has errors? Select multiple
System.out.print("Hello World")
System.out.print(Hello World);
System.out.Print("Hello World);
System.out.print("Hello World");
Indicate the actual output of the statements below:
int thisYear = 2020;
System.out.println("The current year is "+thisYear);
The current year is thisYear
The current year is 2020
No output; an error exists
The current year is
Which of the following is used as a terminator in Java programming?
)
;
.
>
Is the entry point into the application.
Public
Static
Void
main()
A ______ should always start with an uppercase first letter.
Object
Class
Variable
Array
CLR is the .NET equivalent of _________.
Java Virtual Machine
Common Language Runtime
Common Type System
Common Language Specification
Boxing converts a value type on the stack to an ______ on the heap.
Bool type
Instance type
Class type
Object type
The character pair ?: is a________________available in C#.
Unary operator
Ternary operator
Decision operator
Functional operator
A _______ is an identifier that denotes a storage location
Constant
Reference type
Variable
Object
_________ are reserved, and cannot be used as identifiers.
Keywords
literal
variables
Identifiers
An _______ is a symbol that tells the computer to perform certain mathematical or logical manipulations.
Operator
Expression
Condition
Logic
What is the Size of ‘Char’ datatype?
8 bit
12 bit
16 bit
18 bit
Which of the following is correct about variable naming conventions in C#?
It should not be keyword
It must not contain any embedded space or symbol
both of the above
none of the above
CLR is responsible for __________ ?
Garbage-collector
Code access security
Code verification
all are true
Correct syntax for do while loop is :
do; { statement; }while (condition);
do(condition) { statement; }while;
do { statement; }while (condition)
do { statement; }while (condition);
______ are used for naming classes, methods, variables etc.
All of the mentioned
Keywords
Constants
Identifiers
