Home

Java Programming MCQ Solved Paper for DRDO

Thursday 9th of March 2023

Sharing is caring

1. 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
2. Java is fully object oriented programme.
A. true
B. false
C.
D.
Answer : A
3. If a=10 and b= 15, then the statement x =(a>b)?a:b; assigns the value 15 to x.
A. True
B. False
C.
D.
Answer : A
4. The name of the RMI compiler is ___________
A. rmicom
B. rmic
C. jrmi
D. none of the above
Answer : B
5. All methods in an abstract class must be declared abstract.
A. True
B. False
C.
D.
Answer : B
6. 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
7. 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
8. 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
9. The setBackground() method is part of the class
A. Applet
B. Component
C. Container
D. Object
Answer : B
10. 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
11. Which of the following are not keywords?
A. NULL
B. Implements
C. Protected
D. None of the above
Answer : A
12. 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
13. Servlet can have ___________
A. get method and post method
B. get method or post method
C. Either of the above
D.
Answer : C
14. 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
15. 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
16. Which of the following are keywords?
A. integer
B. default
C. Boolean
D. Object
Answer : B
17. Which of the following are the wrapper classes?
A. Random
B. Vector
C. Byte
D. all of the above
Answer : C
18. 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
19. 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
20. Which javadoc tag is used to denote a comment for methods parameters?
A. @method
B. @parameter
C. @argument
D. @param
Answer : D
21. 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
22. When we implement the Runnable interface, we must define the method
A. start()
B. init()
C. runnable()
D. run()
Answer : D
23. class.forName(...) creates an instance of java ODBC driver
A. True
B. False
C.
D.
Answer : A
24. 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
25. Objects are passed to a method by use of call-by-reference.
A. True
B. False
C.
D.
Answer : A
26. A Java monitor must either extend thread class or implement Runnable interface.
A. True
B. False
C.
D.
Answer : B
27. Frames and applets cannot be used together in the same program.
A. True
B. False
C.
D.
Answer : B
28. Which of the following represent legal flow control statements?
A. break();
B. continue(inner);
C. return;
D. exit();
Answer : C
29. 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
30. A class may be both abstract and final.
A. True
B. False
C.
D.
Answer : B
31. 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
32. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
33. 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
34. A constructor must always invoke its supper class constructor in its first statement.
A. True
B. False
C.
D.
Answer : B
35. If a=10 and b= 15, then the statement x =(a>b)?a:b; assigns the value 15 to x.
A. True
B. False
C.
D.
Answer : A
36. Which of the following classes are available in the java.lang package?
A. Random
B. Stack
C. String Buffer
D. Vector
Answer : A
37. 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
38. One the features of is that an array can store many different types of values.
A. True
B. False
C.
D.
Answer : B
39. 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
40. The default case is always required in the switch selection structure.
A. True
B. False
C.
D.
Answer : B
41. The check box group class is a subclass of the component class.
A. True
B. False
C.
D.
Answer : B
42. An EJB is a server-side component that encapsulates the business logic of an application
A. True
B. False
C.
D.
Answer : A
43. Two methods cannot have the same name in Java.
A. True
B. False
C.
D.
Answer : B
44. With javadoc, which of the following denotes a javadoc comment?
A. //#
B. /*
C. /**
D. //**
Answer : C
45. 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
46. 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
47. Declarations can appear anywhere in the body of a Java method.
A. True
B. False
C.
D.
Answer : A
48. 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
49. In RMI before running the client program we must start RMI Registry.
A. True.
B. False.
C.
D.
Answer : A
50. 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

Sharing is caring