You are on page 1of 6

(a) min(0 (b) max()

Multiple Choice Questions


1. (c) abs() (d) all of the
Among
have a body.
the following, which method does not
Which of these have the highest
mentioned
precedence
(a) A class (b) ++
(a) 0
(b) An interface (c)
* (d) >
(c) An abstract method 12. Modulus operator, %, can be applied to.
(d) None of the above (a) Integers
2. Which
language was developed as the first purely (b) Floating-point numbers
object programming language? (c) Both Integers and floating - point number
(a) Java oers
(b) C+ None of the above
(c) Small talk (d)
(d) Kotlin 13. The Math class is included in which
3.
Among the following, which is not valid class java package
specifier? (a) Java.io (b) Java.lang
(a) Protected (b) Private (c) Java.util (d) Java.sys
(c) Pointer 14. To display the date and time in java which
(d) Public package
4.
Among the following, which is not an OOP'S
isincluded?
concept? (a) Java.util." (b) Java. Date.
(a) Encapsulation (b) Exception ()Java.io. (d) Java.lang
() Abstraction (d) Polymorphism 15. What does the
object has ?
5. Which among the
following is not a Java feature? (a) Attributes (b) State
(a) Use of pointers
()Behaviour (d) All of the above
(b) Architecture Neutra from Question 16-20 find the odd one out:
(c) Object-oriented 16. (a) Code Reusability
(d) Dynamic (b) Efficient code
6. Which is the minor integer data type? (c) Duplicate /redundant data
(a) Byte (b) Long (d) Modularity
(c)short (d) int 17.
7.
(a) Data hiding
Among the following, which is not a
primitive
data type? (6) Data Binding
(a) enum (b) Short () Message passing
(c) Byte (d) Int (d) Platform independent
8. Which of the statement 18. (a)
satisfies the empty
loop in Constructor and Destructor
java (b) Inheritance and
(a) It has an empty conditional clause (C)
Polymorphism
Structure and Union
(b) It has an empty increment clause (d) Class and
(c) It has an empty initialization clause 19. (a)
Object
if 0
(d) All of above
(b) for)
9. Among the following classes, superclass a
of all (c) Continue
other classes is?
(a) Math (d) break
(b) Process 20. (a)
(c) System (d) Object Integer stream
10. Which of the function is (b) Short stream
a
rounding function of
Math class? (c) Byte stream
(d) Long stream
Functions can't
return objects. 35. Multiple branches is used
(b) False statement
by
(a) True

AWHILE loop in Java executes the statements at (a) Break (b) Switch
22
even the condition is not satisfied (c) Continue
least once (d) Loop
(b) False 36. AWT stand
(a) True
for
What is the output ofa Logical
is
OR (1) operation if (a) All Window Tools
the inputs/operands true
one of (b) All Writing Tools
(a) True (b) False (c) Abstract Window Toolkit
carn return a value
4 Constructor (d) Abstract Writing Toolkit
(a) True (b) False 37. Valid declaration of a char is
5 A loop in Java generally contains a Loop-Counter (a) char ch ="\utea'; (b) char ca
='tea';
variable.
(c) char cr \u0223;=

(d) char cc =
"\itea';
(a) True (b) False
38. types of polymorphism
invented OOPS.
26. (a) 3 (b) 2
(a) Alan Kay (b) Dennis Ritchie
(c)5 (d) 4
(c) Adele Goldberg (d) Andrea Ferro
39. User-defined structure adds the function of
27. An OOPS program
can contain no of
encapsulation
classes.
(a) True (b) False
(a) Only 999 (b) Only 100
40. To find the square of a number, Which of the
(c) Only 1 (d) Any number following statement is false
28. The object cannot be_
(a) Math.pow(a,2) (b) Aa
(a) passed by value (b) passed by copy (c) Math.sqrt(a,2) (d) All of the above
(c) passed by function
41. Java compiler javac translates Java source code
(d) passed by reference into
29. The Java program use to find and
(a) Assembler language
fix bugs
(b) Byte code
(a) JDB (b) JRE (c) Bit code
(c) JVM (d) JDK
(d) Machine code
30. Byte Data Type range is .
42. In Java,character constant's value is its
a integer
(a)-128to 128 -127 to 128
(b) value in the character set.
(c)-128to 127 (d) -127 to 127
(a) EBCDIC b) Unicode
1. Size of integer in Java Programming (c) ASCII (d) Binary
is 43. An abstract data type typically comprises a
(a) 8 Bytes (b) 1 Bytes and a set of_ respectively.
(c) 2 Bytes (d) 4 Bytes
(a) representation, classes
Data
methods of
2 To access the instance variables and (b) Database, operations
is used
class objects in java, (c) Data representation, objects
(b) instance of
(a) dot operator() (d) Data representation, operations.
(d) conditional
(c) bitwise
operator decreases the value by_ ProgrammingBased Question
number A4. What is the result of the expression float a =35/0?

(a) 4 (b) 1 (a) Infinity


(d) 3 (b) Run time exception
(c) 2
Not a number
34. Exit controlled loop i s (c)
(b) While (d) 0
(a) for
(d) If lese
(c) Do while
of the tollowin
45. Evaluate the following expression, if x=3, y=5, and 56. With javadoc,
which
ing denotes a
javadoc comment?
Sa
z=10:
(a) 1/ (b)
+z+y-y + z+xt+
(c)*
(d) /*
(a) 23 (b) 25
times "Hello' is printed?
(c) 20 (d) 24 57. How many
Public static void main(String args[|)
46. The result of the
expressiorn of 818.
(a) 64 (b) 1
(c)8 for(i 0;i<5;it+)
(d) 16
47. What will be the value
of expression a/b? If a=14 System.out.println("hello");
and b 4, both a,b are type int
(a) 3 (b) 2 break;
(c) 4 (d) 1
48. If a user wants to execute a loop 10 times, which of
the following statement will be used (a) 5 (b) 4
(a) for(i-6;i-26;i-i+2) (c) 1 (d) 0
(6) for(i-3;i-30;i-i+3) 58. Public

(c)for(i-0;i<10;j-i+) Class Yes


(d) All of the above Public
49. Math. ceil(46.6) output is? Static void main(Stringll args)
(a) 46.5 (b) 46.6
() 46.0 (d) 47.0 for (inti=0; i< 10; it+)
50. Math.floor(46.6) output is ? Int x 10;
(a) 46.0 (b)-46.00
(c) 47 (d) 46.5
51. Give the value of the Output above prg will give as
following expression
6-2+10%4+7 (a) 10(10 times) (b) 10
(a) 13 (b) 10 (C) no output (d) Compile time error
(c)12 (d) 14 59. If(a=0)
52. What will be the result of the
expression
J%k when j-10 and k=3 If(a-0)
(a) 0 (b) 1
(c) 2 (d) 3
53. What will be the result of the System.out.println("1 ");
expression -14%-3
(a) 2
(b)-2 Else
(c)4 (d) 4
54. Evaluate the following Java expression,
y-5, and z=10:
if x=3, System.out.println("2 ");
++z+y-y+z+xtt
(a) 24 (b) 23
(c)20 (d) 25 System.out.println("3
Above will
");
55. What is the
type and value of the give output as
following (a) 12
expression? (Notice the integer division) (c) 3
(b) 13
4+1/2+2*-3+5.0 60. Class full (d) 23
(a) int -5 (b) double -4.5
(c) int-4 (d) double -5.0
Public static void
main(String args|)
65. The following program is based on the
Intx=3.14; specification given below. Fill in the blanks with
appropriate java statements.
Inty(int) Math.floor(x);
System.out.print(y); class name : hello
we have first initialized the two variables i and k
with the values 2 and 1 respectively.
What will be the output while loopis used with the condition ++i< 6. Thus,
(b) 3 the value of i will increase by 1 before it can be
(a))0
) 4 (d) 3.0 used further because of a preceding ++ operator
in the condition.then assignment operator will
1, What will be the value of x after executing the
following statement be used between k and i. So the value of k will
become 3.this will continue till the value of k will
xxy)? (y+X): (y-x);
If int x=15; y=20; become60
(a) 5 (b) 15 class (a) .
(c) 25 (d) 35
62. Class A public static (b) main(String
args[])
Public static void main(String | args)
int i-(c) k=1;
Intx=11 &9; while (++is<6)
Inty = x 3; (d)
System.out.println( y | 12 ); System.out.println(e)

(a) ) hello
Output of the above will be
(a) 14 (b) 0 (ii) class
(c) 7 (d) 8 (ii) void

63. Class abc (b) (i) class


(i) void
Public static void main(String args[]) (ii) object
) (i) i= 1
(ii) i = 2
Intg 5;
System.out.print(+g * 8);
(ii) i = 0

(d) i)k=i
i ) i* = k;

What will be the ouput ii) k=i;


(b) 56
(a) 44 (e) ()(k)
(d) 40 i) (i)
(c) 48
64. Given (i) (6)
=
{1,2,3,4,5,6,7,8,9,10; 66. The following program is based on the
nt values[] specification given below. Fill in the blanks with
for(int i-0;i< Y; ++i) appropriate java statements
System.out.printin(values[i]);
class name: calculate
of value[i]?
Find the value we have first initialized the
two variables x
(b) 11
with the values and y
50 and 5 vice versa..
(a) 10 None of the above or
(d)
(c) 15
for evaluation, which is
Then the while loop is executed to check of x 15 expressions
value of the first operands
based on the
less then equal to y,then y is divided by x.
The loop will execute 2 times. After 2 iterations (a) if (c> d)
y becomes less than x so condition of while loop x=C
becomes false and it stops executing. else
class (a). x = d;

(?)
public static void main((b) (i) x=(c>d) ? d: d;
argsl) (i) x = (c>d) ? c: c;
ii) x = (c >d) ? d: c;
int x=(c) y-(d) (iv) x = (c >d) ? c:d;

(b) ?:are
while(x=y) G) Conditional operators'
(ii) Arithmetic operators
y= (e).
(iii) Bitwise operator
System.out.println(y); (iv) Assignment operator
(c) If else Statement
(i) One-way selection statement
(ii) Two-way selection statement
(a) (i) class
(ii) Multi-way selection statement
(ii) calculate
(ii) void
(iv) Multipath decision statement.

(b) i) string (d) What is the other name for (? :) Question Mak
Colon Operator.?
(ii) void
(ii) calculate () Comparison Operator
(i) IE-Else Operator
(c)i)x=50 (ii) Binary Operator
(i) x = 5

(ii) x = 1 iv) Ternary Operator


68. Java offers a rich set of operators to manipulae
(d) (i) y= 50
i) y = 5
variables. Operator in Java is a symbol that is
used to perform operations. For example: t
(ii) y= 1
etc.Operators are special symbols that execute
(e) ) y/x Specific operations on one, two, or three operands
(i) x/y and then return a result.
Operators with higner
Gii) y/y precedence are evaluated before operatos
with relatively lower
Case Study precedence. Operato
on the same line have equal precedence. Wneu

67. Read the given below and answer the questions operators of equal precedence seem in a Simia
given below expression, a rule must govern, which is asses
first. the
Conditional operators are
merely a condensed Entirely binary operators except pr

to
form of the if-else Statement which also
returns
assignment operators areassessed from ft
a value. Conditional right; assignment operators are evaluateu
night
Operators Java are also
in
to the left. *= operator. It us
known as ternary operators. The term is
ternary assignment
an
the
is used because this operator consists an
arithmetic operator like +,
of three or a
operands used to evaluate Boolean expressions. assignment operator (a single'=).
The ultimate aim of the operator is to
decide (a) int k-1,i-2;
which value is to be assigned to the
variable,
The Java Conditional Operator selects one of
while(+i<6)
two k-i;
System.out.println(k); the switch statement
Predict the output (a) int main()
() 30 ii) 60

(ii) 20 iv) 50 while(true)


k*=i; is equal to
(b)
(ii) k =k+i;
(i) k =k*i;
iv) k= k/i;
System.out.println("RABBIT");
break;
(ii) k k i;
= -

(C) return 0;
(i) Increment operator
(ii) Decrement operator
(ii) Arithmetic operator Predict the output
(i) RABBIT
(iv) None of the above
(ii) RABBIT is printed an unlimited number of
(d) Types of Integers are. times.
) short (ii) int (ii) No output
(ii) long (iv) all of the above
(iv) Compiler error
69. While workingwith loops, it is sometimes
needed to skip some statements inside the loop
(b) Loops in are implemented using.
or terminate the loop immediately without
i) While Block (ii) For Block
examining the test expression. In such cases, (ii) Do While Block(iv) All the above
break and continue statements are used. Break (c) What is the way to come out of or Quit any
statement in Java terminates the loop immediately, Loop suddenly
and the program's control transfers to the next ) quit; statement
statement following the loop. It is almost used (ii) leave; Statement
with decision-making statements (Java if..else (ii) break; statement
Statement). It can be used to terminate a case in
(iv) continue; Statement

You might also like