WorksheetsICSE 9 Java computer applications final exam
Total questions: 113
Worksheet time: 4hrs 59mins
What is the main focus of Object Oriented Programming?
Data-Oriented Programming
Object-Oriented Programming
Functional Programming
Procedural Programming
Which programming language is commonly used for Object Oriented Programming?
JavaScript
C++
Java
Python
What are the building blocks of Object Oriented Programming?
Arrays and Pointers
Loops and Conditions
Objects and Classes
Functions and Variables
Which of the following is a valid data type in Java?
Boolean
String
All of the above
Float
What do operators in Java primarily do?
Control Program Flow
Perform Mathematical Operations
Manipulate Objects
Handle User Input
What is the purpose of Input in Java?
Display Output to the User
Receive Data from the User
Control Program Execution
Perform Calculations
Which category of methods does the Mathematical Library in Java contain?
Mathematical Functions
File Handling Methods
String Manipulation Methods
User Input Methods
What are Conditional Statements used for in Java?
Repeating Code Execution
Handling Errors
Making Decisions
Sorting Data
What is the purpose of Iterative Constructs in Java?
Defining Classes and Objects
Performing Repetitive Tasks
Handling Exceptions
Creating GUI Applications
Which concept is introduced in the course 'Introduction to Java'?
Data Structures
Web Development
Object-Oriented Programming
Functional Programming
What is the fundamental unit of Object-Oriented Programming?
Function
Variable
Object
Loop
Which of the following is a valid value type in Java?
Character
Array
Integer
All of the above
What do Operators in Java help achieve?
Perform Operations on Data
Code Reusability
Efficient Memory Management
Data Encapsulation
What is the primary use of Conditional Statements in Java?
Control Program Flow
Perform Mathematical Operations
Define Classes
Handle User Input
Which type of constructs are used for repetitive tasks in Java?
Conditional Statements
Iterative Constructs
Exception Handling
Object and Classes
\n is used for ______
New line feed
Horizontal tab
Vertical tab
Backspace
Java character set consists of
Letters
Digits
Operators
Delimiters
All of the above
Identify the conversion
a) int a=45;
long b = a;
implicit
explicit
none of these
Identify the Conversion
a) double d=23.67
int a= (int) d;
implicit
explicit
none of these
Which of the following is a conditional statement?
if
if else
if else if
all of the above
Re-write above statement using ternary operator-
if(X<=Y)
X=Y;
else
Y=X;
if(X<=Y) then X=Y else Y=X;
if(X<=Y) ? X=Y : Y=X;
(X<=Y) ? X=Y : Y=X;
What will be the output of following statement-
System.out.println('A'=='a');
true
false
A==a
A=97
What will be the output of following snippet-
Both are not equal
Both are equal
Syntax error
runtime error
int marks = 80;
if( marks > 70 )
System.out.println("Distinction");
System.out.println("Congratulations");
else if( marks > 35 )
System.out.println("Pass");
Distinction
Congratulations
Pass
Distinction
Error ('else' without 'if')
The if -else statement executes a block of code if a specified condition is
true
false
both
none
What is the output of Java program with SWITCH?
int num=20;
switch(num)
{
case 10: System.out.println("TEN"); break;
case 20: System.out.println("TWENTY"); break;
case 30: System.out.println("THIRTY");
}
TEN
TWENTY
THIRTY
TEN TWENTY
What is the output of the below Java program with a SWITCH statement?
int points=6;
switch(points)
{
case 6: ;
case 7: System.out.print("PASS");
case 8: ;
case 9: System.out.print(" Excellent");
case 10: System.out.print(" Outstanding"); break;
default: System.out.print("FAIL");
}
PASS Excellent Outstanding
Excellent
Outstanding
FAIL
What are the keywords used to implement a SWITCH case in Java language?
switch, case
default
break
All of above
Predict the output for the given program
Case 2
Case 3
Default Case
Case 2
Case 3
Default Case
int marks = 50;
if( marks > 70 ){
System.out.println("Distinction");
}
else if( marks > 35 ){
System.out.println("Pass");
}
else{
System.out.println("Fail");
}
Pass
Distinction
Fail
Pass
Fail
What is the output of Java program with SWITCH?
int num=20;
switch(num)
{
case 10: System.out.println("TEN"); break;
case 20: System.out.println("TWENTY"); break;
case 30: System.out.println("THIRTY");
}
TEN
TWENTY
THIRTY
TEN TWENTY
Predict the output?
class jump_statments
{
public static void main(String args[])
{
int x = 2;
int y = 0;
for ( ; y < 10; ++y)
{
if (y % x == 0)
continue;
else if (y == 8)
break;
else
System.out.print(y + " ");
} } }
1 3 5 7
2 4 6 8
1 3 5 7 9
1 2 3 4 5 6 7 8 9
Is "X" printed?
YES
NO
Click ALL answers which result in an "X" printed.
a = 3, b = 3, c = 3
a = 5, b = 4, c = 7
a = 1, b = 3, c = 5
a = 6, b = 4, c = 3
a = 5, b = 5, c = 3
What is output?
Jackson
Memorial
JacksonMemorial
There is no ouptut
What is output?
-1
0
1
2
How many stars are printed?
7
3
4
5
Infinite Loop
In total, how many times is the inner loop executed?
5
10
15
50
Infinite Loop
What does the following code print?
A rectangle of 9 rows with 5 stars per row
A rectangle of 6 rows with 6 stars per row
A rectangle of 7 rows with 5 stars per row
A rectangle of 7 rows with 6 stars per row
Infinite Loop
What does the following code print?
A rectangle of 8 rows with 5 stars per row
A rectangle of 8 rows with 4 stars per row
A rectangle of 6 rows with 5 stars per row
A rectangle of 6 rows with 4 stars per row
Infinite Looo
How many times does the following method print a *?
9
6
7
10
If a loop condition is never satisfied then the loop does not execute.
1 2 4 8 16 32 64
1 2 4 8 16 32
2 4 8 16 32 64
2 4 8 16 32
4 8 16 32 64
2
5
7
9
13
20
0.0
-4.0
5
The program will end successfully, but nothing will be printed.
Nothing will be printed. Run-time error: ArithmeticException.
size of double data type is ______________
8 bits
32 bits
16 bits
64 bits
How many stars are printed?
7
3
4
5
Infinite Loop
PREDICT THE OUTPUT:
int x = 60;
int y = 90;
if (y%x == 0 && y-x==30)
{
System.out.println("Hello World");
}
else
{
System.out.println("Error")
}
Hello World
Hello world
Error
Hello World
Error
2
5
7
9
13
20
-1 0 2 5
-1 0 3 7
-1 1 4 8
0 2 5 9
0 1 3 7
Which is the alternative to SWITCH in Java language?
break, continue
for, while
if-else
goto, exit
What is the output of Java program with SWITCH below?
int a=10;
switch(a)
{
case 10: System.out.println("TEN");
}
No Output
TEN
Compiler error as there is no break
None
What is the output of Java program below?
int num=40;
switch(num)
{
case 5: System.out.println("FIVE"); break;
case 35+5: System.out.println("FORTY"); break;
case 20+30: System.out.println("FIFTY");
}
FIVE
FORTY
FIFTY
Error
What is the output of the below Java program?
int persons = 45;
int random = 45;
switch(random)
{
case persons: System.out.print("CRICKET ");
default: System.out.println("RUGBY");
}
CRICKET
CRICKET RUGBY
RUGBY
Compiler error
if a = 30, then value of b = a--+--a
b= 56
b= 58
b= 57
b= 59
if p=10, then the output of the expression c= p++ *5 is
50
55
45
0
The output of the following statements will be
int a = 14; b= 4;
boolean x=(a>b)? true:false
true
false
error
none of the above
In this expression the ________ logical operator that will be performed first _
((a>b)&&(b>c))||(b>a)!(c>b))
&&
||
!
?
Evaluate the following expression if the value of x=2, y=3 and z=1.
v = x + ––z + y++ +y
(a)
If int y = 10 then find int z = (++y * (y++ + 5))
(a)
What will be the output of the following code?
char x = ‘A’; int m;
m = (x == ‘a’) ? ‘A’ : ‘a’;
System.out.print(m);
(a)
Which of the following operators will give either a true or a false value as an output
Relational
Bitwise
Logical
Ternary
What is the output of the following code
x=9
System.out.print(x++);
9
10
11
8
int sum1 = 100 + 50;
int sum2 = sum1 + 250;
int sum3 = sum2 + sum2;
System.out.println(sum3);
What will be the final output?
950
800
sum2sum2
sum1250
int x = 4;
System.out.println(x < 5 && x < 10);
What will be the output?
false
true
4
x < 5 && x < 10
What is the output of below code?
int x = 5;
System.out.println(x++);
System.out.println(x);
5
5
6
6
5
6
6
5
a=11,b=22
solve= a +b + a++ + b++ + ++a + ++b
103
164
87
94
int x = 0;
while (x < 4) {
x = x + 1;
}
System.out.println("x is " + x);
int count = 0;
while (count < 10) {
System.out.println("Welcome to Java");
count++;
}
int count = 0;
do {
System.out.println("Welcome to Java");
count++;
} while (count < 10);
for (int i = 1; i <= 10; i++) {
System.out.print(i + " ");
i++;
}
int y = 0;
for (int i = 0; i<10; ++i) {
y += i;
}
System.out.println(y);
for (int i = 1; i < n; i++) {
// iteration
}
Which of the following includes the correct syntax for a for loop?
for(int i = 0, i<10, i++)
for(int i =0, run = 10)
for(int i = 0; run = 10)
for(int i = 0; i < 10; i++)
What is ouptut by the code? Pretend it says System.out.println
2
3
4
5
6
What is the final value of x?
int x = 0;
for(int i = 1; i < 8; i += 3)
x += i;
12
22
7
0
infinite loop
What is the final value of x?
int x = 3;
while (x > 5)
x++;
6
5
4
3
infinite loop
int count = 0;
while (count < 10) {
System.out.println("Welcome to Java");
count++;
}
int x = 0;
while (x < 4) {
x = x + 1;
}
System.out.println("x is " + x);
int count = 0;
do {
System.out.println("Welcome to Java");
count++;
} while (count < 10);
int count = 0;
while (count < 100) {
// Point A
System.out.println("Welcome to Java!");
count++;
// Point B
}
// Point C
for (int i = 0; i < 10; i++)
for (int j = 0; j < 10; j++)
System.out.println(i * j);
for (int i = 1; i < n; i++) {
// iteration
}
int number = 6;
while (number > 0) {
number -= 3;
System.out.print(number + " ");
}
Which is the alternative to SWITCH in Java language?
break, continue
for, while
if-else
goto, exit
What is the output of the below Java program with a SWITCH statement?
int points=6;
switch(points)
{
case 6: ;
case 7: System.out.print("PASS");
case 8: ;
case 9: System.out.print(" Excellent");
case 10: System.out.print(" Outstanding"); break;
default: System.out.print("FAIL");
}
PASS Excellent Outstanding
Excellent
Outstanding
FAIL
Complete the code below to create an object of Scanner class:
Scanner sc = new Scanner( (a) );
Name the package that contains Scanner class.
(a)
Name the type of error in case given below:
Missing semicolon.
Syntax Error
Logical Error
Run-time error
Name the keyword, to use the classes defined in a package.
(a)
Name the package that is invoked by default.
(a)
What is the method of initialization performed in the following statements?
double x=Math.sqrt(16);
System.out.println(x);
Initialization during Declaration
Call to a Method
Referencing another Variable
All of the above
Predict the output of the following code if the values of
l and b are 6 and 5 respectively.
class rectangle_demo
{
static void areaPerimeter(int l,int b)
{
int a,p;
a=l*b;
p=2*(l+b);
System.out.println(a);
System.out.println(p);
}
}
30 23
29 30
30 22
27 22
This function returns the maximum of 2 numbers
Math.min()
Math.max()
Math.minmax()
All mathematical functions are included in a class called
Math
System
Scanner
Math class is a part of Java.________ package
io
util
lang
what will be the output of Math.sqrt(-4.0)
2
-2
NaN
What will be the return value of Math.pow(2.0,3.0)
8.0
8
NaN
In the function Math.pow(a,b), b ( the index)can take a negative value
True
False
NA
The return value of Math.cbrt(-15.625) is
2.5
-2.5
NaN
__________ function returns the magnitude of the number without the sign
Math.round
Math.floor
Math.abs
The return data type for the Math.round() is________
float
integer
double
The return value for Math.round(-51.2) is
-51
-50
-52
Math.ceil() will always return _____ data type
integer
float
double
The output of the function Math.ceil(-31.987)
-31
-32
-30
The output of the function Math.ceil(-9.0)
-9
-8
-10
The output of Math.floor(36.987) is
36
37
35
The output of the function Math.floor(-0.9)
1
0
-1
This functions returns a random number between 0 and 1
Math.round()
Math.random()
Math.intrandom()
The methods which are created by system developers are called _________
library method
built-in method
both
Math.random()*n+1 generates number between
1 and 0
1 and n
0 and n
Math.random()*(n-m) +m generates a number between
m and n
n and m
1 and m
Math.max(-43,-41) will return
-43
-41
NaN
