JAVA QB-4
JAVA QB-4
Question Bank
Unit-4
1. Package in Java is a mechanism to encapsulate a
(a) Classes
(b) Interfaces
(a) intf
(b) Intf
(c) interface
(d) Interface
(a) pkg
(b) Pkg
(c) package
(d) Package
4. Which of these is a mechanism for naming and visibility control of a class and its content?
(a) Object
(b) Packages
(c) Interfaces
5. Which of this access specifies can be used for a class so that its members can be accessed by a
different class in the same package?
(a) Public
(b) No Modifier
(c) Protected
<br>
6. Which of these access specifiers can be used for a class so that its members can be accessed by a
different class in the different package?
(a) Public
(b) Private
(c) Protected
(d) No Modifier
(a) java.awt
(b) java.applet
(c) java.io
(d) java.awt.image
(a) java.io
(b) java.awt
(c) java.applet
(d) java.lang.reflect
9. Which of this package is used for handling security related issues in a program?
(a) java.security
(c) java.io.security
(d) java.lang.security
(a) True
(b) False
12. Which of the following is the correct way of importing an entire package 'pkg'?
(d) A package can be renamed without renaming the directory in which the classes are stored
15. What is the correct way to implement an interface? Example, 'Operation' interface implements
'Add' class.
16. Which of the following is the correct way of implementing an interface A by class B?
(a) True
(b) False
18. Which of these keywords is used by a class to use an interface defined previously?
(a) import
(b) Import
(c) implements
(d) Implements
19. Which of the following is correct way of implementing an interface salary by class manager?
(a) Interfaces are specified public if they are to be accessed by any code in the program.
(b) Interfaces specifies what class must do but not how it does.
(c) All variables in interface are implicitly fnaland statie.Public static final regardless
(d) Allvariables are static and methods are public if interface is defined pubic.
(a) Yes
<br>
(b) No
(a) Static
(b) Protected
(c) Private
(a) Implements
(b) Extends
(c) Inherit
(d) None
<br>
(a) True
(b) False
28. An statement can be used to access the classes and interface ofa different package from the
current package.
(a) import
(b) extends
(c) instanceOf
(d) implement
29. Which of the following packages is used to includes classes to create user interface like Button
and Checkbox?
(a) java.io
(b) java.net
(c) java.awt
(d) java.lang
30. Which of the following package stores all the standard java classes?
(a) Java
(b) Lang
(c) Util
(d) Java.packages
31. Which of these class allows us to get real time data about private and protected member of a
class?
(a) java.io
(b) Getinformation
(c) ReflectPermission
(d) MembersPermission
<br>
(a) java.rmi
(b) java.awt
(c) java.util
(d) java.applet
(a) public
(b) abstract
34. Java Class implementing an Interface can define a variable with the same name as that of the
A
(b) False
35. A Java Interface can not declare constructors. State True or False.
(a) True
(b) False
37. Java Interface DEFAULT methods have with the existing project code. compatibility
(a) Forward
(b) Backward
<br>
(a) packages
(b) subpackages
41. What happens when we access the same variable defined in two interfaces implemented by the
same class?
42. Can "abstract" keyword be used with constructo, Initialization Block, Instance Initialization and
Static Initialization Block. Milo
(a) True
<br>
(b) False
43. A Static method of an Interface should be accessed with and a DOT operator.
(a) Class Name
package pkg:
class output
{
s1.setCharAt(1, x);
System.out.println(s1);
(a) xello
(b) XXXXx
(c) Hxllo
(d) Hexlo
45. Which of these is the method which is executed first before execution of any other thing takes
place in a program?
46. Which of these can be used to differentiate two or more methods having the same name?
<br>
10
47. All Java methods must have a return type. (True / False)
(a) True
(b) False
48. State True or False. A Java method can have the same name as the class name.
(a) True
(b) False
(a) enum
<br>
11
(b) structure
(c) union
(d) function
52. What is the return type of a method that does not return any value?
(a) int
(c) double
(b) float
(d) void
53. What is the process of defining more than one method in a class differentiated by method
signature?
54. Which of the following is a method having same name as that of it's class?
(a) class
(b) finalize
(c) delete
(d) constructor
(b) Allobject of a class are allotted memory for the all the variables defined in the class
(c) If a function is defined public it can be accessed by object of other class by inheritation
(d) All object of a class are allotted memory for the methods defined in the class