Home

Java Programming 1000+ MCQ with answer for RRB ALP

Thursday 9th of March 2023

Sharing is caring

1. 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
2. We can over load methods with differences only in their return type.
A. True
B. False
C.
D.
Answer : B
3. The length of a string object 's1' can be obtained using the expression s1.length.
A. True
B. False
C.
D.
Answer : B
4. The import statement is always the first no comment statement in a Java program files.
A. True
B. False
C.
D.
Answer : B
5. The keywords reserved but not used in the initial version of Java re:
A. Synchronized
B. Boolean
C. union
D. goto
Answer : D
6. 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
7. The check box group class is a subclass of the component class.
A. True
B. False
C.
D.
Answer : B
8. If m and n are int type variables, what will be the result of the expression
'm % n' when m = -14 and n = -3?

A. 4
B. 2
C. -2
D. -4
Answer : C
9. Two methods cannot have the same name in Java.
A. True
B. False
C.
D.
Answer : B
10. Which of the following methods can be used to change the size of a
size() *
resize()

A. component
B. dimension()
C. setSize()
D. size()
Answer : C
11. Which of the following are not keywords?
A. NULL
B. Implements
C. Protected
D. None of the above
Answer : A
12. 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
13. Which of the following are keywords?
A. integer
B. default
C. Boolean
D. Object
Answer : B
14. 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
15. The setBackground() method is part of the class
A. Applet
B. Component
C. Container
D. Object
Answer : B
16. 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
17. A method declared as static can not access non-static class members.
A. True
B. False
C.
D.
Answer : A
18. 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
19. Which javadoc tag is used to denote a comment for methods parameters?
A. @method
B. @parameter
C. @argument
D. @param
Answer : D
20. We can add more than one class(es) at the time of compilation Java Beans.
A. True.
B. False.
C.
D.
Answer : A
21. Which exception is thrown by the read() method of InputStream class?
A. IOException
B. FileNotFoundException
C. ReadException
D. None of the above
Answer : A
22. To delete a file, we can use an instance of class file.
A. True
B. False
C.
D.
Answer : A
23. When we implement an interface method, it should be declared as public.
A. True
B. False
C.
D.
Answer : A
24. Java is fully object oriented programme.
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. Consider the following class definitions:
 class maths { 
student student1;
}
class student {
String name;
}

This code represents:


A. an 'is a' relationship
B. a 'has a' relationship
C. both
D. neither
Answer : B
27. Submit button always fires doPost(...)
A. True
B. False
C.
D.
Answer : B
28. 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
29. In RMI before running the client program we must start RMI Registry.
A. True.
B. False.
C.
D.
Answer : A
30. Every call to wait has a corresponding call to notify that will eventually end the wafting.
A. True
B. False
C.
D.
Answer : A
31. forName() is a static factory method
A. True
B. False
C.
D.
Answer : A
32. 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
33. A Java monitor must either extend thread class or implement Runnable interface.
A. True
B. False
C.
D.
Answer : B
34. A class may be both abstract and final.
A. True
B. False
C.
D.
Answer : B
35. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
36. Any class may be inherited by another class in the same package.
A. True
B. False
C.
D.
Answer : B
37. 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
38. 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
39. 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
40. A catch can have comma-separated multiple arguments.
A. True
B. False
C.
D.
Answer : B
41. When we invoke repaint () for a Component, the AWT invokes the method:
A. draw()
B. update()
C. show()
D. paint()
Answer : B
42. Any method in a supper class can be over ridden in its subclass.
A. True
B. False
C.
D.
Answer : B
43. 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
44. class.forName(...) creates an instance of java ODBC driver
A. True
B. False
C.
D.
Answer : A
45. Message-Driven beans act as a listener for the Java Message Service API, processing messages synchronously
A. True
B. False
C.
D.
Answer : B
46. Java always provides a default constructor to a class.
A. True
B. False
C.
D.
Answer : B
47. A constructor must always invoke its supper class constructor in its first statement.
A. True
B. False
C.
D.
Answer : B
48. 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
49. A variable declared inside the for loop control can not be referenced out side the loop.
A. True
B. False
C.
D.
Answer : A
50. Objects are passed to a method by use of call-by-reference.
A. True
B. False
C.
D.
Answer : A

Sharing is caring