Font size
WorksheetsPF201: SCCPF2012223
Total questions: 50
Worksheet time: 1hrs 15mins
Which of these is an incorrect Statement?
It is necessary to use new operator to initialize an array
Array can be initialized using comma separated expressions surrounded by curly braces
Array can be initialized when they are declared
None of the mentioned
What will be the output of the shown Java code?
0 2 4 6 8
1 3 5 7 9
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
What will be the output of the shown Java code?
3
1
6
2
What will be the output of the Java code above?
31
32
33
34
Which of the following operators can operate on a boolean variable?
1. &&
2. ==
3. ?:
4. +=
3 & 2
1 & 4
1, 2 & 4
1, 2 & 3
Which of these is returned by “greater than”, “less than” and “equal to” operators?
Integers
Floating – point numbers
Boolean
None of the mentioned
What will be the output of the shown Java code?
1
0
true
false
What will be the output of the shown Java code?
1
2
3
Runtime Error
Which of the following is not a decision making statement?
if
if-else
switch
do-while
What is true about do statement?
do statement executes the code of a loop at least once
do statement does not get execute if condition is not matched in the first iteration
do statement checks the condition at the beginning of the loop
do statement executes the code more than once always
Which of these data type can be used for a method having a return statement in it?
void
int
float
both int and float
What will be the output of the shown Java program?
0
1
6
25
What should be expression1 evaluate to in using ternary operator as in this line?
expression1 ? expression2 : expression3
Integer
Floating – point numbers
Boolean
None of the mentioned
What will be the output of the shown Java program?
10 5
5 10
0 10
0 5
It can be defined as a blueprint from which you can create an individual object.
Object
Class
Methods
State
It is the hardware or software environment in which a program runs.
Platform
IDE
Compiler
Editor
A variable which is declared as static is called _______________. It cannot be local.
local variable
static variable
normal variable
instance variable
A variable declared inside the class but outside the body of the method, is called _________________________.
local variable
instance variable
static variable
normal variable
What will be the output of the following Java code?
1
0
true
false
Int value [ ] is a format used to represent-
Command
List
Value
Array
Modulus operator, %, can be applied to which of these?
Integers
Floating – point numbers
Both Integers and floating – point numbers
None of the mentioned
Which one is a valid declaration of a boolean?
boolean b1 = 1;
boolean b2 = ‘false’;
boolean b3 = false;
boolean b4 = ‘true’
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;
1, 2 & 3
1 & 4
1, 2, 3 & 4
3 & 2
public class MyClass {
public static void main(String[] args) {
(a) ("Hello World");
}
}
Attributes of an object are also known as
methods
properties
classes
functions
Which from the following is a feature that allows us to perform a single action in different ways.
Abstraction
Polymorphism
Encapsulation
Inheritance
The process by which objects of one class acquire the properties of objects of another class is known as
Polymorphism
Inheritance
Data Hiding
Association
Which of the these is the functionality of ‘Encapsulation’?
Binds together code and data
Using single interface for general class of actions
Reduce Complexity
All of the mentioned
Which part of this for-statement tells how a variable or initial expression is changed or updated with every loop.
(a)
Please fill the blank of the written Java syntax below:
public class MedApp {
public static void main (String[] args){
Scanner sc = new Scanner( (a) );
}}
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");
}
}}
Explain at least in 1 paragraph the difference between Array and Array of Object.
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];
}}
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();
}}
Please fill the blank of the written Java syntax below:
public class Exercise2 {
public (a) void main(String[] args) {
System.out.println(24+26);
}
}
Please fill the blank of the written Java syntax below:
public class Exercise5 {
public static void main(String[] args) {
Scanner in = new Scanner( (a) );
}
}
Please fill the blank of the written Java syntax below:
public (a) Exercise2 {
public static void main(String[] args) {
System.out.println(24+26);
}
}
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();
}}
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");
}
}}
Which superclass member won’t be accessible to the subclass?
Public member
Private member
Protected member
All of the above
OOP involves use of a number of interacting (a) , each responsible for their own data and operations on it.
Package used to scan input from the user.
import java.util.Scan;
import java.util.*;
import java.util.Get;
import java.util.Scanner;
It is the name of the variables that the programmer indicated and it is used to read and write to the variable.
Identifiers
Datatype
Variables
Concatenation
What is an array in Java?
A collection of different data types
A collection of variables with the same data type
A variable that can hold only one value at a time
A method for storing Strings
How do you declare an array in Java?
int array = new int[];
int[] array = new int();
int array[];
array int[];
Fill in the blank to declare and initialize an integer array with values 1, 2, and 3:
{1, 2, 3}
new int[] {1, 2, 3}
(1, 2, 3)
[1, 2, 3]
What is the output of the following code?
50
70
80
90
What is the index of the first element in an array?
0
1
-1
The size of array
The number system that consists of 1’s and 0’s.
(a)
