JAVA QUESTION
1) What will be the output of following program?
A)9
B)8
C)Run time error
D)Compilation error
Ans) D
2) Which of the following statements is correct?
a) Public method is accessible to all other classes in the hierarchy
b) Public method is accessible only to sub classes of its parent
class
c) Public method can only be called by object of its class
d) Public method can be accessed by calling object of the public
class
Ans)A
3) What will be the output of the following Java program?
a) 0
b) 1
c) Runtime error
d) classname@hashcode in hexadecimal form
Ans)D
4) What is the output of relational operators?
a) Integer
b) Boolean
c) Characters
d) Double
Ans)B
5) What will be the output of the following Java code?
a) 1
b) 2
c) Run time error owing to division by zero in if condition
d) Unpredictable behavior of program
Ans)B
6)Which of these operators can skip evaluating right hand operand?
a) !
b) |
c) &
d) &&
Ans)D
7)Which component is used to compile, debug and execute java program?
a) JVM
b) JDK
c) JIT
d) JRE
Ans)B
8) Which statement is true about java?
a) Platform independent programming language
b) Platform dependent programming language
c) Code dependent programming language
d) Sequence dependent programming language
Ans)A
9) Which of the below is invalid identifier with the main method?
a) public
b) static
c) private
d) final
Ans)C
10)What is the extension of compiled java classes?
a) .class
b) .java
c) .txt
d) .js
Ans)A
11)How to sort an array?
a) Array.sort()
b) Arrays.sort()
c) Collection.sort()
d) System.sort()
Ans)B
12) What is the stored in the object obj in following lines of Java
code?
Box=obj;
a) Memory address of allocated memory of object
b) NULL
c) Any arbitrary pointer
d) Garbage
Ans)B
13) Which of these statement is incorrect?
a) Every class must contain a main() method
b) Applets do not require a main() method at all
c) There can be only one main() method in a program
d) main() method must be made public
Ans)A
14) What is the process of defining two or more methods within same
class that have same name but different parameters declaration?
a) method overloading
b) method overriding
c) method hiding
d) none of the mentioned
Ans)A
15) What will be the output of the following Java code?
a) 10 20
b) 20 10
c) 20 40
d) 40 20
Ans)B
16) What will be the output of the following Java code?
a) 10 20
b) 20 10
c) 20 40
d) 40 20
Ans)A
17) What will be the output of the following Java code?
a) 5
b) 6
c) 7
d) 8
Ans)C
18) What will be the output of the following Java code?
a) int float method
b) float int method
c) compile time error
d) run time error
b) Ans)C
19)What is the process of defining a method in terms of itself, that
is a method that calls itself?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Recursion
Ans)D
19) Which of these classes is not included in java.lang?
a) Byte
b) Integer
c) Array
d) Class
Ans)C