Home

Java Programming MCQ Solved Paper for GATE

Thursday 9th of March 2023

Sharing is caring

1. In RMI before running the client program we must start RMI Registry.
A. True.
B. False.
C.
D.
Answer : A
2. In RMI we invoke client method from remote server
A. True
B. False
C.
D.
Answer : B
3. To delete a file, we can use an instance of class file.
A. True
B. False
C.
D.
Answer : A
4. Two methods cannot have the same name in Java.
A. True
B. False
C.
D.
Answer : B
5. putValue(...) method takes _____________________-
A. Two arguments of object type
B. First one is of a character type and second one is of an object type
C. First one is of an object type and second one is of a character type
D. None of the above.
Answer : A
6. 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
7. Members of a class specified as private are accessible only to the methods of the class.
A. True
B. False
C.
D.
Answer : A
8. For all insert, update, delete, query operations on a database, ResultSet object creation is mandatory.
A. True.
B. False.
C.
D.
Answer : B
9. 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
10. Any class may be inherited by another class in the same package.
A. True
B. False
C.
D.
Answer : B
11. 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
12. Java is fully object oriented programme.
A. true
B. false
C.
D.
Answer : A
13. 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
14. 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
15. A class may be both abstract and final.
A. True
B. False
C.
D.
Answer : B
16. A constructor must always invoke its supper class constructor in its first statement.
A. True
B. False
C.
D.
Answer : B
17. The setBackground() method is part of the class
A. Applet
B. Component
C. Container
D. Object
Answer : B
18. 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
19. 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
20. A method declared as static can not access non-static class members.
A. True
B. False
C.
D.
Answer : A
21. One the features of is that an array can store many different types of values.
A. True
B. False
C.
D.
Answer : B
22. 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
23. Which exception is thrown by the read() method of InputStream class?
A. IOException
B. FileNotFoundException
C. ReadException
D. None of the above
Answer : A
24. 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
25. We can over load methods with differences only in their return type.
A. True
B. False
C.
D.
Answer : B
26. Which of the following represent legal flow control statements?
A. break();
B. continue(inner);
C. return;
D. exit();
Answer : C
27. 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
28. Consider the following class definition.
Class Student extends String
{
}
What happens when we try to compile this class?

A. Will not compile because class body is not defined
B. Will not compile because class is not declared public
C. Will compile successfully.
D. Will not compile because String is abstract
Answer : D
29. Declarations can appear anywhere in the body of a Java method.
A. True
B. False
C.
D.
Answer : A
30. Which of the following are not keywords?
A. NULL
B. Implements
C. Protected
D. None of the above
Answer : A
31. 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
32. When we implement the Runnable interface, we must define the method
A. start()
B. init()
C. runnable()
D. run()
Answer : D
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. Which javadoc tag is used to denote a comment for methods parameters?
A. @method
B. @parameter
C. @argument
D. @param
Answer : D
35. 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
36. Every call to wait has a corresponding call to notify that will eventually end the wafting.
A. True
B. False
C.
D.
Answer : A
37. 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
38. It is perfectly legal to refer to any instance variable inside of a static method.
A. True
B. False
C.
D.
Answer : B
39. 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
40. 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
41. Declaring a method synchronized guarantees that the deadlock cannot occur.
A. True
B. False
C.
D.
Answer : A
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. When we invoke repaint () for a Component, the AWT invokes the method:
A. draw()
B. update()
C. show()
D. paint()
Answer : B
44. The break statement is required in the default case of a switch selection structure.
A. True
B. False
C.
D.
Answer : B
45. 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
46. 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
47. 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
48. The name of the RMI compiler is ___________
A. rmicom
B. rmic
C. jrmi
D. none of the above
Answer : B
49. 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
50. With javadoc, which of the following denotes a javadoc comment?
A. //#
B. /*
C. /**
D. //**
Answer : C

Sharing is caring