Professional Documents
Culture Documents
4) When you compile a java program, the compiler converts a human readable source file into platform
independent code that a JVM can understand. What is this platform independent cod called?
(a) API
(b) Bytecode
(c) Class
(d) Package
5) What is JVM?
(a) All java files are compiled into class files that contain JVM.
(b) It is an abstract machine that hides underlying operating system from java applications and executes
the java bytecode.
(c) It is libraries of compiled code that can be used in java programs.
(d) It is a java program that contains many classes.
8) Reducing a problem or task into relevant and necessary details is an example of the ________ principle.
(a) Interface
(b) Abstraction
(c) Encapsulation
(d) Modularity
9) Designing a class so that it shields certain parts of an object from other objects is an example of the
____________ principle.
(a) Interface
(b) Abstraction
(c) Encapsulation
(d) Modularity
10) The _______ of an application is visible to user and all other functionality remains hidden.
(a) Interface
(b) Abstraction
(c) Encapsulation
(d) Inheritance
12) __________ members are accessible from classes in the same package only.
(a) private
(b) protected
(c) public
(d) default
13) __________ members are accessible in the same package and sub class.
(a) private
(b) protected
(c) public
(d) default
18) Prototype for the returnable function xyz( ) which returns a boolean value and accepts an integer and
character through its parameter list, is:
(a) void xyz( )
(b) int xyz(char t, int b, int y)
(c) void xyz(int a, char b)
(d) boolean xyz(int a, char b)
19) A function which does not change the state of its object :
(a) Pure function
(b) Impure function
(c) Calling function
(d) Called function
24) During function call, the actual parameter gets copied to the formal parameter(in call by value). This is known
as:
(a) static binding
(b) dynamic binding
(c) Holistic binding
(d) All of the above
(a) 0123456789
(b) 012
34
56
78
9
(c) 01
23
45
67
89
(d) None of these
26) Polymorphism is implemented in software using:
(a) Dynamic binding
(b) Function calling
(c) Function overloading
(d) None of the above
27) The following function is a part of some class which computes and returns the greatest common divisor of
any two numbers.
There are some places in the code marked by ?1?, ?2?, ?3?, ?4? and ?5? which must be replaced by
statement/expression so that the function works correctly.
28) State the final value of q at the end of the code segment:
(a) 28
(b) 27
(c) 30
(d) 29
29) The following function is a part of some class which checks if a positive integer is an Armstrong number by
returning true or false.
( A number is said to be Armstrong if the sum of cubes of all its digits is equal to the original number) the
function does not use modulus operator(%) to extract digit.
There are some places in the code marked by ?1?, ?2?, ?3?, ?4? and ?5? which must be replaced by
statement/expression so that the function works correctly. The statements / expressions at these places will
be:
(a) (1) 0 (2) 0 (3) digit (4) num/10 (5) num==sum
(b) (1) 0 (2) s+f (3) digit*digit*digit (4) f/10 (5) digit==sum
(c) (1) 0 (2) f (3) digit*digit*digit (4) num/10 (5) num==sum
(d) (1) 0 (2) f*10 (3) digit*digit*digit (4) f (5) N==sum
(a) b is 5
(b) No output
(c) a is 10
(d) None of these
35) A JAVA PROGRAM EXECUTES BUT DOES NOT GIVE THE DESIRED OUTPUT .IT IS DUE TO THE
(a) LOGICAL ERROR
(b) SYNTATICAL ERROR
(c) GRAMMATICAL ERROR
(d) NONE
(a) 2 9 28 65
(b) 1 8 27 64 125
(c) 0 7 26 63 124
(d) 0 7 26 63
39) Access specifier that allows member variables of a class to be used by all the classes in the same package as
well as all the subclasses outside the package.
(a) public
(b) private
(c) protected
(d) friendly
41) Fill in the blank numbered from (A) to(D) 4 in the following program that attempts to find 5 n :
class Power
{
int getresult ( __(A)__)
{
int pro = __(B)__ ;
for(int i = 1; I <= n; i++)
pro = pro * __(C)__ ;
__(D)__ ;
}
void callerFunct ( )
{
int p;
p = getresult(5); //calling function getresult ( )
System.out.print (p);
}
}
43) Which of the following is incorrect regarding final keyword used in Java?
(a) the variable declared as final become constant
(b) the member function declared as final can be overridden
(c) the class declared as final can not be inherited
Correct answer : b
(a) 10
(b) 15
(c) 3
(d) 30
Correct answer : a
49) Which java classes are required to write and read binary files?
(a) StringTokenizer class
(b) FileReader, FileWriter
(c) FileOutputStream, FileInputStream
(d) Math class
52) Which function closes the stream and releases the resources that were busy in the stream?
(a) finish()
(b) close()
(c) stop()
(d) end()
59) How the features and behaviour of a real-world object are depicted in software terms?
(a) Features by variables and Behaviour by methods.
(b) Features by methods and Behaviour by variables.
(c) By packages.
(d) By polymorphism.
60) The two-step process of converting source code to machine code involves?
(a) Step 1: Java Compiler Step 2: Java Virtual Machine.
(b) Step 1: Java Virtual Machine. Step 2: Java Compiler
(c) Step 1: Class Step 2: Objects.
(d) Step 1: Abstraction Step 2: Encapsulation
63) Which block executes no matter whether an exception takes place or not?
(a) try
(b) catch
(c) finally
(d) all of the above
66) Primitives and Reference data types allow us to store which values respectively?
(a) int and char
(b) char and int
(c) Rvalue and lvalue
(d) lvalue and rvalue
69) Select the correct output of the statement System.out.println((int)’A’ + 1 + ’1’ + ’A’)?
(a) 132
(b) 180
(c) 130
(d) String
73) String x = “123.45”. Which of the following statements will not produce any error?
(a) double y=Double.parseDouble(x);
(b) Double y=Double.parseDouble(x);
(c) double y=double.parseDouble(x);
(d) double y=double.parsedouble(x);
74) What will be the value of x and y after execution of following statements:
x = 10, y = 2; y *= ++x – x + y++;
(a) x = 11, y = 4
(b) x = 4, y = 11
(c) x = 10, y = 3
(d) x = 11, y = 3
75) Which statement of the following will declare a constant alpha and assign the last lowercase vowel in
alpha?
(a) char alpha=’u’;
(b) this char alpha=’u’;
(c) final char alpha=’u’;
(d) const char alpha=’u’;
77) If the values of a and b are 5 and -5 then what will be the output of the following statement:
System.out.println( !(a == b && b != Math.abs(a))),?
(a) 10
(b) 0
(c) true
(d) false
78) If the values of x and y are true and false respectively then what will be the output of the following
statement?
System.out.println(x = = y ? false : true);?
(a) 0
(b) 1
(c) true
(d) false
82) Which of the following statements will print true as output if the value of a is 9?
(a) System.out.println(a = 9);
(b) System.out.println(a = = 9);
(c) System.out.println(a * 1);
(d) System.out.println(a % 9);
83) How many bytes will be required if one variable of each datatype (byte, short, char, double) are used?
(a) 13 Bytes
(b) 12 Bytes
(c) 16 Bytes
(d) 1 + 4 + 2 + 8 Bytes
(a) 20,4
(b) 10,5
(c) 20,5
(d) 24,7
(a) a
(b) a up to infinite times
(c) abcd
(d) 979899100
if(per >= 90.0 && maths >= 95.0 && computer == 100)
System.out.println(“Admission granted”);
else
System.out.println(“Admission not granted”);
(a) Nested if
(b) if else if ladder
(c) switch statement
(d) Iterative statements
90) Write the output of the following code if the value of channel is 301?
switch (channel)
{
case 301: System.out.println(“Star news”);
case 302: System.out.println(“BBC news”);
case 303:
System.out.println(“News Channel”);
break;
case 105:
case 107:
case 102:
System.out.println(“Entertainment Channel”);
break;
}
(a) Star news
BBC news
News Channel
(b) News Channel
(c) News Channel
Entertainment Channel
(d) Error
91) In the code given below, which variable(s) can be used by the own class and only subclasses of Superclass
class Superclass
{
public int a;
private int b;
protected int c;
char d;
}
(a) a
(b) b
(c) c
(d) d
92) What will be the output of the above code?
class Jagat
{
public static void main(String args[])
{
int a = 10;
{
int b = 5;
}
System.out.println(b);
}
}
(a) 5
(b) 15
(c) Error
(d) 0
(a) 1
(b) 1
2
(c) 1
3
(d) 1
2
3
94) Method void digitFrequency() has been coded to find frequency of each digit present in the number and
display it. Based on it answer the questions (A) to (E).
void digitFrequency()
{ for(int i = 0; i <= 9; i++)
{ int c = ?1?;
int ?2? = i;
while(n != 0)
{ d = ?3?;
if(?4?)
c++;
}
?5?(c > 0)
System.out.println(I + ”\t” + i);
}
}
95) Which statement stands true with regard to invoking a method by passing a value of primitive data type:
(a) Changes made in formal parameters are not reflected in actual parameters
(b) Changes made in formal parameters are reflected in actual parameters
(c) Changes made in actual parameters are not reflected in formal parameters
(d) Changes made in actual parameters are reflected in actual parameters
96) We do not need to create an object to access a class(static) method. Which one of the following is the perfect
example endorsing the above statement?
(a) Math.sqrt()
(b) Scanner sc=new Scanner(System.in);
(c) Student ob=new Student();
(d) StringTokenizerst=new StringTokenizer(“hello friends”,” “);
97) The keyword which resolves the conflict when names of global and local variables are same?
(a) new
(b) final
(c) this
(d) class
99) With respect to the following code, answer questions (A) and (B)
booleanArmstrongNum( int N )
{
int sum = ?1?
int Num = N;
while(num > 0)
{
int f = num / 10;
int digit = num % 10;
sum = ?2?;
num = num / 10;
}
if(sum = N)
return true;
else
return false;
}
100)The following is a function of some class which checks if a positive integer is an Armstrong number by
returning true or false, A number is said to be an Armstrong if the sum of the cube of all its digit is equal to
the original number the function does not use the modulus (%) operator to extract digits. Answer the
questions (A) to (E)