Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

T&P Java Test-1

Total questions: 60

Worksheet time: 30mins

Name
Class
Date
1.

Is this a valid statement and why?


long i = 1;

double d = i + 1;

a)

Yes, the compiler casts automatically

b)

No, the cast needs to happen manually

c)

Yes, because range of int is smaller then the range of double

d)

No, double has a smaller range than int

2.

_________ data type is used to store 'true' or 'false' value

a)

boolean

b)

int

c)

float

d)

char

3.

size of double data type is ______________

a)

8 bits

b)

32 bits

c)

16 bits

d)

64 bits

4.

Which of the following is NOT a primitive datatype?

a)

byte

b)

boolean

c)

String

d)

int

5.

Which of these is necessary condition for automatic type conversion in Java?

a)

The destination type is smaller than source type

b)

The destination type is larger than source type

c)

The destination type can be larger or smaller than source type

d)

None of the mentioned

6.

What will be the error in the following Java code?

byte b = 50;

b = b * 50;

a)

b cannot contain value 100, limited by its range

b)

* operator has converted b * 50 into int, which can not be converted to byte without casting

c)

b cannot contain value 50

d)

No error in this code

7.

If an expression contains double, int, float, long, then the whole expression will be promoted into which of these data types?

a)

long

b)

int

c)

double

d)

float

8.

Can 8 byte long data type be automatically type cast to 4 byte float data type?

a)

True

b)

False

9.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

10.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

11.

The name of the following should be the file name in Java

a)

Object Name

b)

Variable Nam

c)

Class Name

d)

Array Name

12.

Java program is

a)

Interpreted

b)

Compiled

13.

Java program does not run without below function

a)

user()

b)

system()

c)

main()

d)

void()

14.

A ___________ file is created after successful compilation of a Java program.

a)

Object file

b)

Array file

c)

Class file

d)

String file

15.

Command to compile Java program

a)

javax

b)

javay

c)

javac

d)

Java

16.

Command to run a Java program

a)

javaa

b)

java

c)

jaava

d)

jaavaa

17.

JDK stands for

a)

Java Developer Kit

b)

Java Development Kit

c)

Java Design Kit

d)

Java Debugging Kit

18.

JRE stands for

a)

Java Run Environment

b)

Java Run Execution

c)

Java Runtime Environment

d)

Java Ready Execution

19.

Java is

a)

Machine dependent language

b)

Machine independent language

20.

Java program does not run without below function

a)

user()

b)

system()

c)

main()

d)

void()

21.

Which of the following is incorrect?

a)

int count = 50.0;

b)

int salary = 50_000;

c)

int salary = 50_00;

d)

all of these are incorrect

22.

Determine whether the following identifier is true/false.

int _$c;

a)

True

b)

False

23.

Determine whether the following identifier is true/false.

int 2_w;

a)

True

b)

False

24.

Determine whether the following identifier is true/false.

int .f;

a)

True

b)

False

25.

Determine whether the following identifier is true/false.

int -d;

a)

True

b)

False

26.

Determine whether the following identifier is true/false.

int _$;

a)

True

b)

False

27.

Determine whether the following identifier is true/false.

int this_is_a_detailed_name_for_identifier;

a)

True

b)

False

28.

Determine whether the following identifier is true/false.

int :b;

a)

True

b)

False

29.

Determine whether the following identifier is true/false.

int e#;

a)

True

b)

False

30.

Determine whether the following identifier is true/false.

int 7g;

a)

True

b)

False

31.

Determine whether the following identifier is true/false.

int _a;

a)

True

b)

False

32.

Which of the following is a valid Java keyword?

a)

var

b)

123switch

c)

_if

d)

public

33.

Choose the invalid variable name in Java.

a)

myVariable

b)

$variable

c)

_variableName

d)

123variable

34.

Identify the invalid variable name in Java.

a)

myVariable

b)

$variable

c)

_variable Name

d)

variable123

35.

Identify the invalid variable name in Java.

a)

myVariable

b)

*variable

c)

_variableName

d)

variable123

36.

Which of the following is a valid Java keyword?

a)

var

b)

123switch

c)

_if

d)

public

37.

What is the correct rule for identifiers in Java?

a)

Identifiers can start with a number

b)

Identifiers can contain special characters like @, #, and %

c)

Identifiers are case-insensitive

d)

Identifiers cannot be a keyword

38.

Which of the following is a valid variable name in Java?

a)

123variable

b)

_variable

c)

variable$

d)

variable_name

39.

What is the correct rule for identifiers in Java?

a)

Identifiers can start with a number

b)

Identifiers can contain special characters like @, #, and %

c)

Identifiers are case-insensitive

d)

Identifiers cannot be a keyword

40.

What is the correct rule for identifiers in Java?

a)

Identifiers can start with a special character

b)

Identifiers can have spaces in between

c)

Identifiers cannot be a reserved keyword

d)

Identifiers can be of any length

41.

Which of the following is a valid variable name in Java?

a)

123variable

b)

_variable

c)

variable$

d)

variable_name

42.

Which of the following is the correct main() method signature in Java?

a)

public static void main (String [] args)

b)

public static void Main (String [] args)

c)

public static void main (string [] args)

d)

public static void main (String args)

43.

Which of the following is a valid variable declaration in Java?

a)

int 1myInteger = 0;

b)

int int = 0;

c)

Int my Integer = 0;

d)

int myInteger = 0;

44.

Which of the following is a reserved word in Java?

a)

export

b)

import

c)

input

d)

output

45.

Which of this command has errors? Select multiple

a)

System.out.print("Hello World")

b)

System.out.print(Hello World);

c)

System.out.Print("Hello World);

d)

System.out.print("Hello World");

46.

Indicate the actual output of the statements below:

int thisYear = 2020;

System.out.println("The current year is "+thisYear);

a)

The current year is thisYear

b)

The current year is 2020

c)

No output; an error exists

d)

The current year is

47.

Which of the following is used as a terminator in Java programming?

a)

)

b)

;

c)

.

d)

>

48.

Is the entry point into the application.

a)

Public

b)

Static

c)

Void

d)

main()

49.

A ______ should always start with an uppercase first letter.

a)

Object

b)

Class

c)

Variable

d)

Array

50.

CLR is the .NET equivalent of _________.

a)

Java Virtual Machine

b)

Common Language Runtime

c)

Common Type System

d)

Common Language Specification

51.

Boxing converts a value type on the stack to an ______ on the heap.

a)

Bool type

b)

Instance type

c)

Class type

d)

Object type

52.

The character pair ?: is a________________available in C#.

a)

Unary operator

b)

Ternary operator

c)

Decision operator

d)

Functional operator

53.

A _______ is an identifier that denotes a storage location

a)

Constant

b)

Reference type

c)

Variable

d)

Object

54.

_________ are reserved, and cannot be used as identifiers.

a)

Keywords

b)

literal

c)

variables

d)

Identifiers

55.

An _______ is a symbol that tells the computer to perform certain mathematical or logical manipulations.

a)

Operator

b)

Expression

c)

Condition

d)

Logic

56.

What is the Size of ‘Char’ datatype?

a)

8 bit

b)

12 bit

c)

16 bit

d)

18 bit

57.

Which of the following is correct about variable naming conventions in C#?

a)

It should not be keyword

b)

It must not contain any embedded space or symbol

c)

both of the above

d)

none of the above

58.

CLR is responsible for __________ ?

a)

Garbage-collector

b)

Code access security

c)

Code verification

d)

all are true

59.

Correct syntax for do while loop is :

a)

do; { statement; }while (condition);

b)

do(condition) { statement; }while;

c)

do { statement; }while (condition)

d)

do { statement; }while (condition);

60.

______ are used for naming classes, methods, variables etc.

a)

All of the mentioned

b)

Keywords

c)

Constants

d)

Identifiers