Home

Java Programming MCQ Solved Paper for NDA

Thursday 9th of March 2023

Sharing is caring

1. 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
2. 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
3. Declarations can appear anywhere in the body of a Java method.
A. True
B. False
C.
D.
Answer : A
4. The break statement is required in the default case of a switch selection structure.
A. True
B. False
C.
D.
Answer : B
5. 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
6. 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
7. In RMI before running the client program we must start RMI Registry.
A. True.
B. False.
C.
D.
Answer : A
8. Which javadoc tag is used to denote a comment for methods parameters?
A. @method
B. @parameter
C. @argument
D. @param
Answer : D
9. 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
10. A class may be both abstract and final.
A. True
B. False
C.
D.
Answer : B
11. 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
12. 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
13. To delete a file, we can use an instance of class file.
A. True
B. False
C.
D.
Answer : A
14. 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
15. 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
16. Which of the following represent legal flow control statements?
A. break;
B. break();
C. continue(inner);
D. all of the above
Answer : A
17. Servlet can have ___________
A. get method and post method
B. get method or post method
C. Either of the above
D.
Answer : C
18. Any class may be inherited by another class in the same package.
A. True
B. False
C.
D.
Answer : B
19. Which exception is thrown by the read() method of InputStream class?
A. IOException
B. FileNotFoundException
C. ReadException
D. None of the above
Answer : A
20. 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
21. 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
22. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
23. forName() is a static factory method
A. True
B. False
C.
D.
Answer : A
24. 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
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. A catch can have comma-separated multiple arguments.
A. True
B. False
C.
D.
Answer : B
27. Which of the following methods belong to the String class?
A. length()
B. compareTo()
C. substring()
D. all of the them
Answer : D
28. Java always provides a default constructor to a class.
A. True
B. False
C.
D.
Answer : B
29. The import statement is always the first no comment statement in a Java program files.
A. True
B. False
C.
D.
Answer : B
30. Which of the following are not keywords?
A. NULL
B. Implements
C. Protected
D. None of the above
Answer : A
31. The check box group class is a subclass of the component class.
A. True
B. False
C.
D.
Answer : B
32. 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
33. 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
34. 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
35. Frames and applets cannot be used together in the same program.
A. True
B. False
C.
D.
Answer : B
36. 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
37. We can add more than one class(es) at the time of compilation Java Beans.
A. True.
B. False.
C.
D.
Answer : A
38. Which of the following command lines options generates documentation for all classes and methods?
A. -protected
B. -public
C. -private
D. -encoding
Answer : C
39. 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
40. JdbcOdbcDriver is an object of Object class
A. True
B. False
C.
D.
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 are keywords?
A. integer
B. default
C. Boolean
D. Object
Answer : B
43. One the features of is that an array can store many different types of values.
A. True
B. False
C.
D.
Answer : B
44. In RMI we invoke client method from remote server
A. True
B. False
C.
D.
Answer : B
45. 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
46. The programmer must explicitly create the system .in and system .out objects.
A. True
B. False
C.
D.
Answer : B
47. 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
48. 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
49. The setBackground() method is part of the class
A. Applet
B. Component
C. Container
D. Object
Answer : B
50. 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

Sharing is caring