Home

1000+ Java Programming MCQ for SBI Clerk [Solved]

Thursday 9th of March 2023

Sharing is caring

1. In evaluating a logical expression of type 'Boolean expression 1&& Boolean expression 2', both the Boolean expressions are not always evaluated.
A. True
B. False
C.
D.
Answer : A
2. If you want to assign a value of 99 to the variable year, then which of the following lines can be used within an <applet> tags?
A. number=getParameter(99)
B. <number==99>
C. D. <param = radius value ==99>
Answer : C
3. In RMI we invoke client method from remote server
A. True
B. False
C.
D.
Answer : B
4. The programmer must explicitly create the system .in and system .out objects.
A. True
B. False
C.
D.
Answer : B
5. 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
6. 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
7. The concept of multiple inheritance is implemented in Java by
A. extending two or more classes
B. extending one class and implementing one or more interfaces
C. all the above
D.
Answer : B
8. Which of the following statements are valid array declarations?
A. int number();
B. float average[];
C. double[] marks;
D. counter int[];
Answer : B
9. In RMI before running the client program we must start RMI Registry.
A. True.
B. False.
C.
D.
Answer : A
10. Which of the following methods can be used to draw the outline of a square?
A. fillRect()
B. drawLine()
C. drawString()
D. all of the above
Answer : B
11. All methods in an abstract class must be declared abstract.
A. True
B. False
C.
D.
Answer : B
12. Which of the following statements are true?
A. An abstract class may not have any final methods?
B. A final class may not have any abstracts methods.
C. Transient variables must be static.
D. all of the above
Answer : B
13. In the code below, what data types the variable x can have?
A. byte b1 = 5;
B. byte b2 = 10;
C. x = b1 * b2;
D. int short
Answer : D
14. A string object can not be modified after it is created.
A. True
B. False
C.
D.
Answer : A
15. 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
16. Which of the following classes are available in the java.lang package?
A. Random
B. Stack
C. String Buffer
D. Vector
Answer : A
17. A panel can not be added to another panel.
A. True
B. False
C.
D.
Answer : B
18. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
19. Servlet has ___________
A. init method
B. doGet(------) method
C. All of the above methods.
D.
Answer : C
20. The import statement is always the first no comment statement in a Java program files.
A. True
B. False
C.
D.
Answer : B
21. Two methods cannot have the same name in Java.
A. True
B. False
C.
D.
Answer : B
22. 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
23. Give file is a file object, which of the following are legal statements to create a new file.
A. file.create();
B. FileOutputStream fos=new FileOutputStream(file);
C. FileInputStream fis=new FileInputStream(file);
D. all of the above
Answer : B
24. 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
25. Message-Driven beans act as a listener for the Java Message Service API, processing messages synchronously
A. True
B. False
C.
D.
Answer : B
26. Objects are passed to a method by use of call-by-reference.
A. True
B. False
C.
D.
Answer : A
27. Session bean
A. Represents a single client inside the application server
B. Can not be shared
C. Is not persistent
D. Satisfies all of the above conditions
Answer : D
28. Declaring a method synchronized guarantees that the deadlock cannot occur.
A. True
B. False
C.
D.
Answer : A
29. A constructor must always invoke its supper class constructor in its first statement.
A. True
B. False
C.
D.
Answer : B
30. When we implement an interface method, it should be declared as public.
A. True
B. False
C.
D.
Answer : A
31. Which javadoc tag is used to denote a comment for methods parameters?
A. @method
B. @parameter
C. @argument
D. @param
Answer : D
32. 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
33. All the bitwise operators have the same level of precedence in Java.
A. True
B. False
C.
D.
Answer : A
34. Any class may be inherited by another class in the same package.
A. True
B. False
C.
D.
Answer : B
35. class.forName(...) creates an instance of java ODBC driver
A. True
B. False
C.
D.
Answer : A
36. Consider the following class definition.
Class Student extends String
{
}
What happens when we try to compile this class?

A. Will not compile because class body is not defined
B. Will not compile because class is not declared public
C. Will compile successfully.
D. Will not compile because String is abstract
Answer : D
37. The expression (x == y && a<b) is true If either x == y is true or a<b is true.
A. True
B. False
C.
D.
Answer : B
38. When we invoke repaint () for a Component, the AWT invokes the method:
A. draw()
B. update()
C. show()
D. paint()
Answer : B
39. 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
40. The setBackground() method is part of the class
A. Applet
B. Component
C. Container
D. Object
Answer : B
41. The keywords reserved but not used in the initial version of Java re:
A. Synchronized
B. Boolean
C. union
D. goto
Answer : D
42. Which of the following methods can be used to remove a component from the display?
A. remove()
B. desappear()
C. hide()
D. move()
Answer : C
43. Every call to wait has a corresponding call to notify that will eventually end the wafting.
A. True
B. False
C.
D.
Answer : A
44. executeUpdate(------------) returns ___________
A. Nothing
B. Returns a ResultSet object
C. Returns an integer value to show the no. of updated rows
D. None of the above.
Answer : C
45. Frames and applets cannot be used together in the same program.
A. True
B. False
C.
D.
Answer : B
46. Servlet can have ___________
A. get method and post method
B. get method or post method
C. Either of the above
D.
Answer : C
47. In a single Servlet class we can use____________
A. doGet(...) method only
B. doPost(...) method only
C. doGet(...) method and doPost(...) method both at a time.
D. Either 'a' or 'b'
Answer : C
48. One the features of is that an array can store many different types of values.
A. True
B. False
C.
D.
Answer : B
49. 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
50. A package is a collection of
A. classes
B. interface
C. editing tools
D. classes and interfaces
Answer : D

Sharing is caring