Home

1000+ Java Programming MCQ for SSC CGL [Solved]

Thursday 9th of March 2023

Sharing is caring

1. JSP files creates ________________
A. html files
B. html files and java files
C. java files and class files
D. None of the above.
Answer : C
2. Message-Driven beans act as a listener for the Java Message Service API, processing messages synchronously
A. True
B. False
C.
D.
Answer : B
3. 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
4. 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
5. DriverManager.getConnection("jdbc:odbc:dsn_name") method does not depend on the class.forName(...) method.
A. True.
B. False.
C.
D.
Answer : B
6. We can add more than one class(es) at the time of compilation Java Beans.
A. True.
B. False.
C.
D.
Answer : A
7. Frames and applets cannot be used together in the same program.
A. True
B. False
C.
D.
Answer : B
8. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
9. Objects are passed to a method by use of call-by-reference.
A. True
B. False
C.
D.
Answer : A
10. What is java -g used for?
A. Using the jdb tool
B. Executing a class with optimization turned off
C. To provided information about deprecated methods
D. Non of the above
Answer : B
11. When we invoke repaint () for a Component, the AWT invokes the method:
A. draw()
B. update()
C. show()
D. paint()
Answer : B
12. Members of a class specified as private are accessible only to the methods of the class.
A. True
B. False
C.
D.
Answer : A
13. Which of the following command lines options generates documentation for all classes and methods?
A. -protected
B. -public
C. -private
D. -encoding
Answer : C
14. 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
15. 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
16. Which of the following string can be used as mode string for creating a RandomAccessFile object?
A. "rw"
B. "wr"
C. "0"
D. 'w''
Answer : A
17. Given the code
String s = new String("abc");
Which of the following calls are valid?

A. s.toUpperCase()
B. s.append("xyz")
C. s.setCharAt(1<'A')
D. all of the above
Answer : A
18. Submit button always fires doPost(...)
A. True
B. False
C.
D.
Answer : B
19. It is perfectly legal to refer to any instance variable inside of a static method.
A. True
B. False
C.
D.
Answer : B
20. A variable declared inside the for loop control can not be referenced out side the loop.
A. True
B. False
C.
D.
Answer : A
21. Servlet can have ___________
A. get method and post method
B. get method or post method
C. Either of the above
D.
Answer : C
22. 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
23. We would like to make a member of a class visible in all subclasses regardless of what package they are in. Which one of the following keywords would achieve this?
A. private
B. protected
C. public
D. private protected
Answer : D
24. The use of protected keyword to a member in a class will restrict its visibility as follows:
A. Visibility only in the class and its subclasses in the same package.
B. Visibility only inside the same package.
C. Visibility in all classes in the same package and subclasses in other packages.
D. Visibility only in the class where it is declared.
Answer : C
25. A static class method can be invoked by simply using the name of the method alone.
A. True
B. False
C.
D.
Answer : B
26. class.forName(...) creates an instance of java ODBC driver
A. True
B. False
C.
D.
Answer : A
27. With javadoc, which of the following denotes a javadoc comment?
A. //#
B. /*
C. /**
D. //**
Answer : C
28. It is perfectly legal to assign a subclass object to a supper class reference.
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. Declaring a method synchronized guarantees that the deadlock cannot occur.
A. True
B. False
C.
D.
Answer : A
31. 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
32. A string object can not be modified after it is created.
A. True
B. False
C.
D.
Answer : A
33. 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
34. A package is a collection of
A. classes
B. interface
C. editing tools
D. classes and interfaces
Answer : D
35. It is an error to catch the same type of exception in two different catch blocks associated with a particular try block.
A. True
B. False
C.
D.
Answer : A
36. 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
37. When present, package must be the first no comment statement in the file.
A. True
B. False
C.
D.
Answer : A
38. Servlet has ___________
A. init method
B. doGet(------) method
C. All of the above methods.
D.
Answer : C
39. 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
40. Declarations can appear anywhere in the body of a Java method.
A. True
B. False
C.
D.
Answer : A
41. Every call to wait has a corresponding call to notify that will eventually end the wafting.
A. True
B. False
C.
D.
Answer : A
42. 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
43. 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
44. The programmer must explicitly create the system .in and system .out objects.
A. True
B. False
C.
D.
Answer : B
45. Connection, Statement are interfaces and ResultSet is a class.
A. True.
B. False.
C.
D.
Answer : B
46. Java always provides a default constructor to a class.
A. True
B. False
C.
D.
Answer : B
47. It is an error if a class with one or more abstract methods is not explicitly declared abstract.
A. True
B. False
C.
D.
Answer : A
48. Which of the following statements are valid array declarations?
A. int number();
B. float average[];
C. double[] marks;
D. counter int[];
Answer : B
49. 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
50. The import statement is always the first no comment statement in a Java program files.
A. True
B. False
C.
D.
Answer : B

Sharing is caring