wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Programming-1

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

1. Which of this method is given parameter via command line arguments?

a)

a) main()

b)

b) recursive() method

c)

c) Any method

d)

d) System defined methods

2.

Which of these data types is used to store command line arguments?

a)

a) Array

b)

b) Stack

c)

c) String

d)

d) Integer

3.

3. How many arguments can be passed to main()?

a)

a) Infinite

b)

b) Only 1

c)

c) System Dependent

d)

d) None of the mentioned

4.

What are the Type Conversions available in Java language?

a)

A) Narrowing Type Conversion

b)

B) Widening Type Conversion

c)

A and B

d)

D) None of the above

5.

Which are the compatible Data Types for Type Promotion or Type Casting?

a)

A) byte, char, short

b)

B) char, int, float

c)

C) float, long, double

d)

D) All the above

6.

What is the output of the below Java code snippet?

char ch = 'A';//ASCII 65

int a = ch + 1;

ch = (char)a;

System.out.println(ch);

a)

A) 66

b)

B) A

c)

C) B

d)

D) 65

7.

Which type of loop is best known for its boolean condition that controls entry to the loop?

a)

A. do-while loop

b)

B. for (traditional)

c)

C. for-each

d)

D. while

8.

What is the output of the following code snippet?

int i = 0; for(i = 0 ; i < 5; i++)

{ }

System.out.println(i);

a)

A. 5

b)

B. 0

c)

C. 4

d)

D. Compilation Error

9.

What will be the Output of the below code:

public class Demo{

public static void main(String[] arr){

}

public static void main(String arr){

}

}

a)

a) Nothing

b)

b) Error

c)

C) Finite

d)

d) Hii

10.

What is the output of the following Java Code?

int a=9;

float b = a/2;

System.out.println(b);

a)

A) 4.0

b)

B) 4.5

c)

C) 5.0

d)

D) None of the above