Java QB
Java QB
a) Inheritance
b) Encapsulation
c) Polymorphism
d) Compilation
2. Which concept of Java is achieved by combining methods and attribute into a class?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Abstraction
3. What is the range of short data type in Java?
a) -128 to 127
b) -32768 to 32767
c) -2147483648 to 2147483647
d) None of the mentioned
4. Which of these values can a boolean variable contain?
a) True & False
b) 0 & 1
c) Any integer value
d) true
5. Which of the below data type doesn’t support overloaded methods for +,-,* and /?
a) int
b) float
c) double
d) BigDecimal
6. An array elements are always stored in ________ memory locations?
a) Sequential
b) Random
c) Sequential and Random
d) Binary search
7. If an expression contains double, int, float, long, then the whole expression will be promoted
into which of these data types?
a) long
b) int
c) double
d) float
8. What is the process of defining more than one method in a class differentiated by method
signature?
a) Function overriding
b) Function overloading
c) Function doubling
d) None of the mentioned
9. Which of the following is a method having same name as that of it’s class?
a) finalize
b) delete
c) class
d) constructor
10. What would be the behaviour if this() and super() used in a method?
a) Runtime error
b) Throws exception
c) compile time error
d) Runs successfully
11. What is true about constructor?
a) It can contain return type
b) It can take any number of parameters
c) It can have any non access modifiers
d) Constructor cannot throw an exception
12. Which of this keyword must be used to inherit a class?
a) super
b) this
c) extent
d) extends
13. Which of these is correct way of inheriting class A by class B?
a) class B + class A {}
b) class B inherits class A {}
c) class B extends A {}
d) class B extends class A {}
14. Which of these can be overloaded?
a) Methods
b) Constructors
c) All of the mentioned
d) None of the mentioned
15. Which of these is an incorrect array declaration?
a) int arr[] = new int[5].
b) int [] arr = new int[5].
c) int arr[] = new int[5].
d) int arr[] = int [5] new
16. Arrays in Java are implemented as?
a) class
b) object
c) variable
d) none of the mentioned
17. Which of these methods must be made static?
a) main()
b) delete()
c) run()
d) finalize()
18. What is the output of relational operators?
a) Integer
b) Boolean
c) Characters
d) Double
19. Which of these is not abstract?
a) Thread
b) AbstractList
c) List
d) None of the Mentioned
20. Which of these packages contains abstract keyword?
a) java.lang
b) java.util
c) java.io
d) java.system
21. String in Java is a?
a) class
b) object
c) variable
d) character array
22. Which of these keywords is used to refer to member of base class from a subclass?
a) upper
b) super
c) this
d) none of the mentioned
23. Which of these method of String class can be used to test to strings for equality?
a) isequal()
b) isequals()
c) equal()
d) equals()
24. Which of these access specifiers must be used for main() method?
a) private
b) public
c) protected
d) none of the mentioned
25. Which of these is used as a default for a member of a class if no access specifier is used for
it?
a) private
b) public
c) public, within its own package
d) protected
26. Which of these packages contain classes and interfaces used for input & output operations
of a program?
a) java.util
b) java.lang
c) java.io
d) all of the mentioned
27. Which of these class is not related to input and output stream in terms of functioning?
a) File
b) Writer
c) InputStream
d) Reader
28. Which of these keywords are used for the block to be examined for exceptions?
a) try
b) catch
c) throw
d) check
29. Which of these keywords are used for generating an exception manually?
a) try
b) catch
c) throw
d) check
30. Which of these keywords is used to define packages in Java?
a) pkg
b) Pkg
c) package
d) Package
31. Which of the following is the correct way of importing an entire package ‘pkg’?
a) import pkg.
b) Import pkg.
c) import pkg.*
d) Import pkg.*
Fill in the blanks:
Java
3. The output of the Java compiler is executed by the ----------_.
JVM
4. -------------------_ is a reference to the current object on which the method
was invoked.
This
21. In Java the looping statements ____,_____ and ______ are used for performing
iteration.
for, while and do...while
22. Java does not allow any type of mismatches of data and hence it is
a_____________typed language.
Strongly
Complier
27. _______________ are similar to program codes without the syntax of a language.
Pseudo code
28. Encapsulation is a concept in OOP which hides unimportant implementation details from other
objects.
29. Java was developed by Sun Microsystems.
30. Languages like Simula, Smalltalk, C++ and Java adopt object oriented approach in
programming.