0% found this document useful (0 votes)
37 views4 pages

Review Test 2

Uploaded by

lily27896
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views4 pages

Review Test 2

Uploaded by

lily27896
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Ashoka Universal School

Academic Session 2024-25


Computer Application
Review Jobsheet 2
Topics Covered: Concepts of OOPS, Features of Java, Classes and Objects, Values and Data
types,Operators and Conditional Construct
Question-1 Choose the correct answer and write the correct option. [30]
i) When an expression consists of int, double, long, float, then the entire expression will
get promoted to a data type that is:
a. float b. double c. int d. long

ii) What does the expression double a = 35 / 0.0 return?


a. 0 b. not a Number c. infinity d. run time exception

iii) Evaluate the following Java expression, if x=3, y=5, and z=10:
x*=++z + y - y + z + x++
a. 24 b. 73 c. 75 d. 25

iv) Which package contains the Scanner class?


a. java.util b. java.lang c. java.awt d. java.io

v) Which keyword is used for accessing the features of a package?


a. package b. import c. extends d. export

vi) An object is created during __________ in Java.


a. compile time b. run time c. assembly time d. debugging time

vii) Creating an object from a class is also called ___________.


a. initializing b. instantiating c. interfacing d. implementing

viii) Java ternary operator is also called _________________.


a. relational Operator b. conditional Operator c. logical Operator d. bitwise Operator

ix) Which of these cannot be used for a variable name in Java?


a. Identifier & keyword b. Identifier c. Keyword d. Operators

x) What is the extension of compiled java program file?


a. .txt b. .jas c. .class d. .java

xi) Name the type of error in the statement given below:


int r= 100/0;
a. Syntax error b. Run time error c. Logical error d. None of the above

xii) Which of these operators is used to allocate memory to array variable in Java?
a. alloc b. malloc c. new d. new malloc

xiii) Modulus operator (%) can be applied to which of these?


a. Integers b. Floating point numbers c. Strings d. Both a and b

xiv) int result = ‘C’; What is the value of result?


a. C b. 67 c. 66 d. 99

xv) Which of the following are not Java keywords?


a. double b. char c. then d. case

Page 1 of 4
xvi) Which of the following statements will terminate the premature execution of a
program?
a. break b. System.exit(0) c. stop d. end

xvii) Choose the odd one out from the following-: --


a)<= b) >= c) < d)!

xviii)A class is used to create similar objects that possess different characteristics and common behaviour.
Hence, a class is termed as an ----
a) Attribute b) Object factory c) Datatype d) Blueprint

xix) Which a1nong the following is not a string literal?


a) "Hello" b) "123" c) "h" d) 10.5

xx) With the help of inheritance, the components in the Base class ,can be reused to
perform some other task in derived class. This phenomenon is termed as ___
a) Binding b) Reusability c) Overloading d) Data hiding

xxi) A method that accepts a character through scanner object


a) next() b) nextLine() c) next().charAt(0) d) next.charAt()

xxii) Out of the following, which is the best data type to store the value 34678 ?
a) long b) byte c) String d) float

xxiii)

Name the OOPs concept of java depicted in the above picture.


a) Encapsulation b) Inheritance c) Abstraction d) Polymorphism

xxiv) Which data types are allowed in a Java switch statement?


a) int, short, byte, double b) String, int, short, char
c) double, float, int d) String, float, double

xxv) out of the following , As a programmer, which error type could not be easily detected
a) syntax errors b) runtime errors c) logic errors

xxvi) What will the output of :


int a=0;
if(a>0 &&a<=1)
a++;
else
a--;
System.out.println(a)
(a) 0 (b) 1 (c) -1 (d) error

xxvii) In a switch case, when the switch value does not respond to any case
then the execution transfers to:
(a) a break statement (b) a default case (c) a loop (d) error

xxviii) Which of the following statements accomplishes 'fall through'?


(a) switch statement (b) if-else (c) ternary operator (d) for statement
Page 2 of 4
For the Assertion(A) and Reason(R) statement questions choose from the below option:
a) Both (A) and (R) are true, and (R) is correct explanation of (A).
b) Both (A) and (R) are true, but (R) is not the correct explanation of (A).
c) (A) is true but (R) is false.
d) (A) is false but (R) is true.

xxix) Assertion (A): switch case is a bidirectional conditional statement


Reason (R): we can check the ranges using switch case

xxx) Assertion(A): Byte code is a platform independent code.


Reason(R): JVM is an interpreter which makes bytecode platform independent by converteing it into
native machine code.

Q2. Solve the following as directed [20]


i) What will be the output of the following code?

class try
{
public static void main(String args[])
{
int y = 10;
int z=y++ ;
System.out.println(y + ", " + z );
}}

ii) What is the output of the following program code?


char ch = ‘D’;
int m = ch;
m = m + 3;
System.out.println( m + “ “ + ch);

iii) differentiate between with example:


a) if else and switch case
b) ! and !=

iv) Write the java expression for the following:


𝑎+𝑏
a) + √4𝑎𝑐 b)2𝑎𝑏 − 𝑚𝑛
2𝑎𝑏
(a+b)/(2*a*b)+Math.sqrt(4*a*c); 2*a*b-Math.pow(m,n);
v) find the output:
int a=4;
switch(a*2)
{
default:
System.out.println(“Five”);
case 18: Five
System.out.println(“Eighteen”); Eighteen
break;
case 10;
System.out.println(“Ten”);}

Page 3 of 4
vi) . Evaluate the output: int a =5,b=2
if( a>b)
{ a=a*(a--+--a+a/2)
a*=a-- + --a +a/2; a=5*(5+3+3/2)
b=++a + a++ +a%2; a=5*(8+1)=45
b=++a+a+++a%2
} b=46+46+47%2
else b=92+2=94
{ a=0;
b=0;
}
System.out.println(a+” “+b);

vii) Find the output for the given snippet:


boolean male = false;
int age = 30;

if( male )
if( age < 20 )
System.out.println("Boy");
else
System.out.println("Man");
else
if( age < 20 )
System.out.println("Girl"); output: Woman
else
System.out.println("Woman");

viii) switch(num)
{
case 5: num++; System.out.println(num);
case 6: System.out.println(“SIX”);
case 7: System.out.println(num);
case 0: num++; System.out.println(“ZERO”+num); break;
case -1: num++; num*=2; System.out.println(num);
default :System.out.println(“Case is not matching”);
} b)
a) output: SIX
a) assume num as -1
0 6
b) assume num as 6
Case is not matching ZERO7
ix) Convert into ternary operator: a=(marks>70)?"Distinction":(marks>35)?"Pass":"Fail";
if( marks > 70 ) System.out.println(a);
System.out.println("Distinction");
OR
else if( marks > 35 ) System.out.println((marks>70)?"Distinction":
System.out.println("Pass");(marks>35)?"Pass":"Fail");
else
System.out.println("Fail");

x) Rewrite Q2 viii) using if-else statement

Page 4 of 4

You might also like