Home

FCI Recruitment - Java Programming 1000+ MCQ [Solved] PDF Download

Thursday 9th of March 2023

Sharing is caring

1. Message-Driven beans act as a listener for the Java Message Service API, processing messages synchronously
A. True
B. False
C.
D.
Answer : B
2. The keywords reserved but not used in the initial version of Java re:
A. Synchronized
B. Boolean
C. union
D. goto
Answer : D
3. The check box group class is a subclass of the component class.
A. True
B. False
C.
D.
Answer : B
4. 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
5. Which exception is thrown by the read() method of InputStream class?
A. IOException
B. FileNotFoundException
C. ReadException
D. None of the above
Answer : A
6. The break statement is required in the default case of a switch selection structure.
A. True
B. False
C.
D.
Answer : B
7. To delete a file, we can use an instance of class file.
A. True
B. False
C.
D.
Answer : A
8. 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
9. Servlet has ___________
A. init method
B. doGet(------) method
C. All of the above methods.
D.
Answer : C
10. 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
11. Which of the following are keywords?
A. integer
B. default
C. Boolean
D. Object
Answer : B
12. 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
13. 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
14. 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
15. A Java monitor must either extend thread class or implement Runnable interface.
A. True
B. False
C.
D.
Answer : B
16. 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
17. 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
18. It is perfectly legal to assign a subclass object to a supper class reference.
A. True
B. False
C.
D.
Answer : A
19. 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
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. 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
22. In RMI before running the client program we must start RMI Registry.
A. True.
B. False.
C.
D.
Answer : A
23. 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
24. Declaring a method synchronized guarantees that the deadlock cannot occur.
A. True
B. False
C.
D.
Answer : A
25. 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
26. A variable declared inside the for loop control can not be referenced out side the loop.
A. True
B. False
C.
D.
Answer : A
27. 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
28. Frames and applets cannot be used together in the same program.
A. True
B. False
C.
D.
Answer : B
29. Members of a class specified as private are accessible only to the methods of the class.
A. True
B. False
C.
D.
Answer : A
30. Which of the following command lines options generates documentation for all classes and methods?
A. -protected
B. -public
C. -private
D. -encoding
Answer : C
31. A class may be both abstract and final.
A. True
B. False
C.
D.
Answer : B
32. A panel can not be added to another panel.
A. True
B. False
C.
D.
Answer : B
33. 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
34. 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
35. forName() is a static factory method
A. True
B. False
C.
D.
Answer : A
36. Submit button always fires doPost(...)
A. True
B. False
C.
D.
Answer : B
37. 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
38. 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
39. The programmer must explicitly create the system .in and system .out objects.
A. True
B. False
C.
D.
Answer : B
40. Which of the following represent legal flow control statements?
A. break();
B. continue(inner);
C. return;
D. exit();
Answer : C
41. 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
42. 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
43. 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
44. A final class may not have any abstract method.
A. True
B. False
C.
D.
Answer : A
45. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
46. 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
47. 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
48. It is perfectly legal to refer to any instance variable inside of a static method.
A. True
B. False
C.
D.
Answer : B
49. 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
50. 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

Sharing is caring