Home

Java Programming 1000+ MCQ with answer for SSC GD

Thursday 9th of March 2023

Sharing is caring

1. 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
2. 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
3. Which exception is thrown by the read() method of InputStream class?
A. IOException
B. FileNotFoundException
C. ReadException
D. None of the above
Answer : A
4. Which of the following represent legal flow control statements?
A. break;
B. break();
C. continue(inner);
D. all of the above
Answer : A
5. A catch can have comma-separated multiple arguments.
A. True
B. False
C.
D.
Answer : B
6. When the string objects are compared with ==, the result is true If the strings contain the same values.
A. True
B. False
C.
D.
Answer : B
7. Two methods cannot have the same name in Java.
A. True
B. False
C.
D.
Answer : B
8. We can add more than one class(es) at the time of compilation Java Beans.
A. True.
B. False.
C.
D.
Answer : A
9. class.forName(...) creates an instance of java ODBC driver
A. True
B. False
C.
D.
Answer : A
10. 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
11. The default case is always required in the switch selection structure.
A. True
B. False
C.
D.
Answer : B
12. A class may be both abstract and final.
A. True
B. False
C.
D.
Answer : B
13. When we invoke repaint () for a Component, the AWT invokes the method:
A. draw()
B. update()
C. show()
D. paint()
Answer : B
14. A package is a collection of
A. classes
B. interface
C. editing tools
D. classes and interfaces
Answer : D
15. An EJB is a server-side component that encapsulates the business logic of an application
A. True
B. False
C.
D.
Answer : A
16. A method declared as static can not access non-static class members.
A. True
B. False
C.
D.
Answer : A
17. Which of the following keywords are used to control access to a class member?
A. default
B. protected
C. interface
D. None of the above
Answer : B
18. The setBackground() method is part of the class
A. Applet
B. Component
C. Container
D. Object
Answer : B
19. DataInput is
A. An abstract class defined is java.io.
B. A class we can use to read primitive data types.
C. An interface that defines methods to open files.
D. An interface that defines methods to read primitive data types.
Answer : D
20. Members of a class specified as private are accessible only to the methods of the class.
A. True
B. False
C.
D.
Answer : A
21. 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
22. A static class method can be invoked by simply using the name of the method alone.
A. True
B. False
C.
D.
Answer : B
23. What does the following line of code do?
TextField text=new TextField(10);

A. Creates text object that can hold 10 rows of text.
B. Creates text object that can hold 10 columns of text.
C. Creates the object text and initializes it with the value 10.
D. The code is illegal.
Answer : B
24. What is error in the following class definitions? 
abstract class xy { 
abstract sum(int x, int y) {
}
}

A. class header is not define properly
B. constructor is no defined
C. method is not defined properly
D. no error
Answer : C
25. EJBs can be of the following type(s)
None of the above

A. Entity Bean
B. Session Bean
C. Message-driven bean
D. All of the above
Answer : D
26. Which are the valid ways to create DataInputStream streams?
A. new DataInputStream(new File("in.dat"));
B. new DataInputStream(new FileInputStream("in.dat"));
C. new DataInputStream("in.dat");
D. new DataInputStream("in.data","r");
Answer : B
27. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
28. 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
29. Any class may be inherited by another class in the same package.
A. True
B. False
C.
D.
Answer : B
30. We can over load methods with differences only in their return type.
A. True
B. False
C.
D.
Answer : B
31. 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
32. With javadoc, which of the following denotes a javadoc comment?
A. //#
B. /*
C. /**
D. //**
Answer : C
33. When we implement an interface method, it should be declared as public.
A. True
B. False
C.
D.
Answer : A
34. Which of the following statements are valid array declarations?
A. int number();
B. float average[];
C. double[] marks;
D. counter int[];
Answer : B
35. 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
36. A string object can not be modified after it is created.
A. True
B. False
C.
D.
Answer : A
37. 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
38. Which of the following statements are true?
A. UTF characters are all 24 bits.
B. Reader class has methods that can read integers and floats.
C. Unicode characters are all 16 bits.
D. all of the above
Answer : C
39. The name of the RMI compiler is ___________
A. rmicom
B. rmic
C. jrmi
D. none of the above
Answer : B
40. 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
41. A panel can not be added to another panel.
A. True
B. False
C.
D.
Answer : B
42. When X is a positive number the operations x>> 2 and x>>>2 both produce the same result.
A. True
B. False
C.
D.
Answer : A
43. When we implement the Runnable interface, we must define the method
A. start()
B. init()
C. runnable()
D. run()
Answer : D
44. Objects are passed to a method by use of call-by-reference.
A. True
B. False
C.
D.
Answer : A
45. The length of a string object 's1' can be obtained using the expression s1.length.
A. True
B. False
C.
D.
Answer : B
46. Which of the following represent legal flow control statements?
A. break();
B. continue(inner);
C. return;
D. exit();
Answer : C
47. The break statement is required in the default case of a switch selection structure.
A. True
B. False
C.
D.
Answer : B
48. All the bitwise operators have the same level of precedence in Java.
A. True
B. False
C.
D.
Answer : A
49. A thread can make second thread ineligible for execution by calling the suspend (-) method on second thread.
A. True
B. False
C.
D.
Answer : A
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