Home

RBI Grade B officer - Java Programming 1000+ MCQ [Solved] PDF Download

Thursday 9th of March 2023

Sharing is caring

1. The keywords reserved but not used in the initial version of Java re:
A. Synchronized
B. Boolean
C. union
D. goto
Answer : D
2. Which of the following classes are available in the java.lang package?
A. Random
B. Stack
C. String Buffer
D. Vector
Answer : A
3. One the features of is that an array can store many different types of values.
A. True
B. False
C.
D.
Answer : B
4. What is wrong in the following class definitions? 
abstract class print { 
abstract show();
}
class Display extends print {
}

A. Nothing is wrong
B. Wrong Method show() should have a return type
C. Wrong Methods show() is not implemented in Display
D. Wrong Display does not contain any members.
Answer : C
5. Which of the following control expressions are valid for an if statement?
A. an integer expression
B. a Boolean expression
C. either A or B
D. Neither A or B
Answer : B
6. A catch can have comma-separated multiple arguments.
A. True
B. False
C.
D.
Answer : B
7. A method declared as static can not access non-static class members.
A. True
B. False
C.
D.
Answer : A
8. An individual array element that is passed to a method and modified in that method will contain the modified value when the called method completes execution.
A. True
B. False
C.
D.
Answer : B
9. The default case is always required in the switch selection structure.
A. True
B. False
C.
D.
Answer : B
10. Message-Driven beans act as a listener for the Java Message Service API, processing messages synchronously
A. True
B. False
C.
D.
Answer : B
11. putValue(...) method takes _____________________-
A. Two arguments of object type
B. First one is of a character type and second one is of an object type
C. First one is of an object type and second one is of a character type
D. None of the above.
Answer : A
12. A variable declared inside the for loop control can not be referenced out side the loop.
A. True
B. False
C.
D.
Answer : A
13. Consider the following code snippet:
try 
{
int x=0; int y=50/x;
System.out.println("Division by zero");
}
catch(ArithmeticException e)
{
System.out.println("catch block");
}

What will be the output?

A. Error. Won't compile
B. Division by zero
C. Catch block
D. Division by zero catch block
Answer : C
14. In order to connect to a database through java program we must create _______-
A. Connection, Statement, ResultSet
B. Connection, ResultSet
C. Statement< ResultSet
D. Connection, Statement
Answer : D
15. Connection, Statement are interfaces and ResultSet is a class.
A. True.
B. False.
C.
D.
Answer : B
16. A class may be both abstract and final.
A. True
B. False
C.
D.
Answer : B
17. Which of the following will produce a value of 10 if x = 9.7?
A. floor(x)
B. abs(x)
C. rint(x)
D. round(x)
Answer : D
18. Objects are passed to a method by use of call-by-reference.
A. True
B. False
C.
D.
Answer : A
19. It is perfectly legal to assign a subclass object to a supper class reference.
A. True
B. False
C.
D.
Answer : A
20. Which of the following represent legal flow control statements?
A. break;
B. break();
C. continue(inner);
D. all of the above
Answer : A
21. The name of a Java program file must match the name of the class with the extension Java.
A. True
B. False
C.
D.
Answer : A
22. Which of the following statements are valid array declarations?
A. int number();
B. float average[];
C. double[] marks;
D. counter int[];
Answer : B
23. If a=10 and b= 15, then the statement x =(a>b)?a:b; assigns the value 15 to x.
A. True
B. False
C.
D.
Answer : A
24. Consider the following statements:
int x = 10, y = 15; 
x = ((x < y) ? (y + x) : (y - x);

What will be the value of x after executing these statements?

A. 25
B. 15
C. 5
D. Error can't be executed.
Answer : A
25. The setBackground() method is part of the class
A. Applet
B. Component
C. Container
D. Object
Answer : B
26. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
27. Members of a class specified as private are accessible only to the methods of the class.
A. True
B. False
C.
D.
Answer : A
28. A JSP file can be stored_________________
A. With the extension .jsp in servlets folder of the jws
B. With the extension .html in public_html folder of the jws
C. With the extension .jsp in public_html folder of the jws
D. None of the above.
Answer : C
29. Consider the following class definitions:
 class maths { 
student student1;
}
class student {
String name;
}

This code represents:


A. an 'is a' relationship
B. a 'has a' relationship
C. both
D. neither
Answer : B
30. Which key word can protect a class in package from accessibility by the classes outside the package?
A. private
B. protected
C. final
D. don't use any keyword at all(make it default)
Answer : D
31. To delete a file, we can use an instance of class file.
A. True
B. False
C.
D.
Answer : A
32. Which exception is thrown by the read() method of InputStream class?
A. IOException
B. FileNotFoundException
C. ReadException
D. None of the above
Answer : A
33. Which of the following command lines options generates documentation for all classes and methods?
A. -protected
B. -public
C. -private
D. -encoding
Answer : C
34. The check box group class is a subclass of the component class.
A. True
B. False
C.
D.
Answer : B
35. Two methods cannot have the same name in Java.
A. True
B. False
C.
D.
Answer : B
36. Declaring a method synchronized guarantees that the deadlock cannot occur.
A. True
B. False
C.
D.
Answer : A
37. The methods wait() and noify() are defined in
A. java.lang.Thread
B. java.lang.Runnable
C. java.lang.Object
D. java.lang.ThreadGroup
Answer : C
38. Which of the following methods can be used to change the size of a
size() *
resize()

A. component
B. dimension()
C. setSize()
D. size()
Answer : C
39. A package is a collection of
A. classes
B. interface
C. editing tools
D. classes and interfaces
Answer : D
40. If m and n are int type variables, what will be the result of the expression
'm % n' when m = -14 and n = -3?

A. 4
B. 2
C. -2
D. -4
Answer : C
41. It is an error to have a method with the same signature in both the super class and its subclass.
A. True
B. False
C.
D.
Answer : B
42. class.forName(...) creates an instance of java ODBC driver
A. True
B. False
C.
D.
Answer : A
43. Frames and applets cannot be used together in the same program.
A. True
B. False
C.
D.
Answer : B
44. Which javadoc tag is used to denote a comment for methods parameters?
A. @method
B. @parameter
C. @argument
D. @param
Answer : D
45. A panel can not be added to another panel.
A. True
B. False
C.
D.
Answer : B
46. Which of the following will produce a value of 22 if x=22.9:
A. Ceil(x)
B. Round(x)
C. Rint(x)
D. Abs(x)
Answer : C
47. Servlet can have ___________
A. get method and post method
B. get method or post method
C. Either of the above
D.
Answer : C
48. executeUpdate automatically updates data because___________
A. auto commit is on, by default
B. It performs a hidden commit statement as well
C. Does not commit
D. None of the above.
Answer : A
49. Any class may be inherited by another class in the same package.
A. True
B. False
C.
D.
Answer : B
50. For all insert, update, delete, query operations on a database, ResultSet object creation is mandatory.
A. True.
B. False.
C.
D.
Answer : B

Sharing is caring