wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PF201: SCCPF2012223

Total questions: 50

Worksheet time: 1hrs 15mins

Name
Class
Date
1.

Which of these is an incorrect Statement?

a)

It is necessary to use new operator to initialize an array

b)

Array can be initialized using comma separated expressions surrounded by curly braces

c)

Array can be initialized when they are declared

d)

None of the mentioned

2.

What will be the output of the shown Java code?

a)

0 2 4 6 8

b)

1 3 5 7 9

c)

0 1 2 3 4 5 6 7 8 9

d)

1 2 3 4 5 6 7 8 9 10

3.

What will be the output of the shown Java code?

a)

3

b)

1

c)

6

d)

2

4.

What will be the output of the Java code above?

a)

31

b)

32

c)

33

d)

34

5.

Which of the following operators can operate on a boolean variable?


1. &&

2. ==

3. ?:

4. +=

a)

3 & 2

b)

1 & 4

c)

1, 2 & 4

d)

1, 2 & 3

6.

Which of these is returned by “greater than”, “less than” and “equal to” operators?

a)

Integers

b)

Floating – point numbers

c)

Boolean

d)

None of the mentioned

7.

What will be the output of the shown Java code?

a)

1

b)

0

c)

true

d)

false

8.

What will be the output of the shown Java code?

a)

1

b)

2

c)

3

d)

Runtime Error

9.

Which of the following is not a decision making statement?

a)

if

b)

if-else

c)

switch

d)

do-while

10.

What is true about do statement?

a)

do statement executes the code of a loop at least once

b)

do statement does not get execute if condition is not matched in the first iteration

c)

do statement checks the condition at the beginning of the loop

d)

do statement executes the code more than once always

11.

Which of these data type can be used for a method having a return statement in it?

a)

void

b)

int

c)

float

d)

both int and float

12.

What will be the output of the shown Java program?

a)

0

b)

1

c)

6

d)

25

13.

What should be expression1 evaluate to in using ternary operator as in this line?


expression1 ? expression2 : expression3

a)

Integer

b)

Floating – point numbers

c)

Boolean

d)

None of the mentioned

14.

What will be the output of the shown Java program?

a)

10 5

b)

5 10

c)

0 10

d)

0 5

15.

It can be defined as a blueprint from which you can create an individual object.

a)

Object

b)

Class

c)

Methods

d)

State

16.

It is the hardware or software environment in which a program runs.

a)

Platform

b)

IDE

c)

Compiler

d)

Editor

17.

A variable which is declared as static is called _______________. It cannot be local.

a)

local variable

b)

static variable

c)

normal variable

d)

instance variable

18.

A variable declared inside the class but outside the body of the method, is called _________________________.

a)

local variable

b)

instance variable

c)

static variable

d)

normal variable

19.

What will be the output of the following Java code?

a)

1

b)

0

c)

true

d)

false

20.

Int value [ ] is a format used to represent-

a)

Command

b)

List

c)

Value

d)

Array

21.

Modulus operator, %, can be applied to which of these?

a)

Integers

b)

Floating – point numbers

c)

Both Integers and floating – point numbers

d)

None of the mentioned

22.

Which one is a valid declaration of a boolean?

a)

boolean b1 = 1;

b)

boolean b2 = ‘false’;

c)

boolean b3 = false;

d)

boolean b4 = ‘true’

23.

With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?


1. x++;

2. x = x + 1;

3. x += 1;

4. x =+ 1;

a)

1, 2 & 3

b)

1 & 4

c)

1, 2, 3 & 4

d)

3 & 2

24.

public class MyClass {

public static void main(String[] args) {

(a)   ("Hello World");

}

}

25.

Attributes of an object are also known as

a)

methods

b)

properties

c)

classes

d)

functions

26.

Which from the following is a feature that allows us to perform a single action in different ways.

a)

Abstraction

b)

Polymorphism

c)

Encapsulation

d)

Inheritance

27.

The process by which objects of one class acquire the properties of objects of another class is known as

a)

Polymorphism

b)

Inheritance

c)

Data Hiding

d)

Association

28.
How many objects can be made from a class? 
a)
None, you make classes from objects
b)
one
c)
As many as you want
d)
All of the above
29.

Which of the these is the functionality of ‘Encapsulation’?

a)

Binds together code and data

b)

Using single interface for general class of actions

c)

Reduce Complexity

d)

All of the mentioned

30.

Which part of this for-statement tells how a variable or initial expression is changed or updated with every loop.

(a)  

31.

Please fill the blank of the written Java syntax below:

public class MedApp {

public static void main (String[] args){

Scanner sc = new Scanner( (a)   );

}}

32.

Please fill the blank of the written Java syntax below:

public class MedApp {

public static void main (String[] args){

if(10 == 5){

System.out.println("True");

} (a)   (5 > 11){

System.out.println("False");

}else{

System.out.println("Not Found");

}

}}

33.

Explain at least in 1 paragraph the difference between Array and Array of Object.

4 lines
34.

 

Please fill the blank of the written Java syntax below:

class Medicine{

}

public class MedApp {

public static void main (String[] args){

Medicine[] meds = new (a)   [100];

}}

35.

 

Please fill the blank of the written Java syntax below:

class Employee{

}

public class MedApp {

public static void (a)   (String[] args){

Employee emp = new Employee();

}}

36.

Please fill the blank of the written Java syntax below:

public class Exercise2 {

public (a)   void main(String[] args) {

System.out.println(24+26);

}

}

37.

Please fill the blank of the written Java syntax below:

public class Exercise5 {

public static void main(String[] args) {

Scanner in = new Scanner( (a)   );

}

}

38.

Please fill the blank of the written Java syntax below:

public (a)   Exercise2 {

public static void main(String[] args) {

System.out.println(24+26);

}

}

39.

Please fill the blank of the written Java syntax below:

class Employee{

}

public class MedApp {

public static void main (String[] args){

(a)   emp = new Employee();

}}

40.

Please fill the blank of the written Java syntax below:

public class MedApp {

public static void main (String[] args){

if(10 == 5){

System.out.println("True");

}else if(5 > 11){

System.out.println("False");

} (a)   {

System.out.println("Not Found");

}

}}

41.

Which superclass member won’t be accessible to the subclass?

a)

Public member

b)

Private member

c)

Protected member

d)

All of the above

42.

OOP involves use of a number of interacting (a)   , each responsible for their own data and operations on it.

43.

Package used to scan input from the user.

a)

import java.util.Scan;

b)

import java.util.*;

c)

import java.util.Get;

d)

import java.util.Scanner;

44.

It is the name of the variables that the programmer indicated and it is used to read and write to the variable.

a)

Identifiers

b)

Datatype

c)

Variables

d)

Concatenation

45.

What is an array in Java?

a)

A collection of different data types

b)

A collection of variables with the same data type

c)

A variable that can hold only one value at a time

d)

A method for storing Strings

46.

How do you declare an array in Java?

a)

int array = new int[];

b)
  • int[] array = new int();

c)

int array[];

d)
  • array int[];


47.

Fill in the blank to declare and initialize an integer array with values 1, 2, and 3:

a)

{1, 2, 3}

b)
  • new int[] {1, 2, 3}

c)

(1, 2, 3)

d)

[1, 2, 3]

48.

What is the output of the following code?

a)

50

b)

70

c)

80

d)

90

49.

What is the index of the first element in an array?

a)

0

b)

1

c)

-1

d)

The size of array

50.

The number system that consists of 1’s and 0’s.

(a)