Home

Java Programming MCQ Solved Paper for RRB Group D

Thursday 9th of March 2023

Sharing is caring

1. Java is fully object oriented programme.
A. true
B. false
C.
D.
Answer : A
2. forName() is a static factory method
A. True
B. False
C.
D.
Answer : A
3. Which of the following methods belong to the String class?
A. length()
B. compareTo()
C. substring()
D. all of the them
Answer : D
4. 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
5. Which of the following represent legal flow control statements?
A. break();
B. continue(inner);
C. return;
D. exit();
Answer : C
6. 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
7. Which javadoc tag is used to denote a comment for methods parameters?
A. @method
B. @parameter
C. @argument
D. @param
Answer : D
8. 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
9. Frames and applets cannot be used together in the same program.
A. True
B. False
C.
D.
Answer : B
10. Message-Driven beans act as a listener for the Java Message Service API, processing messages synchronously
A. True
B. False
C.
D.
Answer : B
11. It is perfectly legal to refer to any instance variable inside of a static method.
A. True
B. False
C.
D.
Answer : B
12. In the code below, what data types the variable x can have?
A. byte b1 = 5;
B. byte b2 = 10;
C. x = b1 * b2;
D. int short
Answer : D
13. 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
14. 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
15. 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
16. 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
17. 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
18. 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
19. 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
20. Members of a class specified as private are accessible only to the methods of the class.
A. True
B. False
C.
D.
Answer : A
21. A final class may not have any abstract method.
A. True
B. False
C.
D.
Answer : A
22. All methods in an abstract class must be declared abstract.
A. True
B. False
C.
D.
Answer : B
23. Which of the following represent legal flow control statements?
A. break;
B. break();
C. continue(inner);
D. all of the above
Answer : A
24. A catch can have comma-separated multiple arguments.
A. True
B. False
C.
D.
Answer : B
25. Any method in a supper class can be over ridden in its subclass.
A. True
B. False
C.
D.
Answer : B
26. 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
27. 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
28. 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
29. The name of the RMI compiler is ___________
A. rmicom
B. rmic
C. jrmi
D. none of the above
Answer : B
30. 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
31. JdbcOdbcDriver is an object of Object class
A. True
B. False
C.
D.
Answer : B
32. 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
33. Java always provides a default constructor to a class.
A. True
B. False
C.
D.
Answer : B
34. Throwing an exception always causes program termination.
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. The setBackground() method is part of the class
A. Applet
B. Component
C. Container
D. Object
Answer : B
37. To delete a file, we can use an instance of class file.
A. True
B. False
C.
D.
Answer : A
38. 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
39. We can add more than one class(es) at the time of compilation Java Beans.
A. True.
B. False.
C.
D.
Answer : A
40. 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
41. 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
42. Servlet has ___________
A. init method
B. doGet(------) method
C. All of the above methods.
D.
Answer : C
43. Which of the following are keywords?
A. integer
B. default
C. Boolean
D. Object
Answer : B
44. When we implement an interface method, it should be declared as public.
A. True
B. False
C.
D.
Answer : A
45. Objects are passed to a method by use of call-by-reference.
A. True
B. False
C.
D.
Answer : A
46. EJBs can be of the following type(s)
None of the above

A. Entity Bean
B. Session Bean
C. Message-driven bean
D. All of the above
Answer : D
47. 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
48. 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
49. A constructor must always invoke its supper class constructor in its first statement.
A. True
B. False
C.
D.
Answer : B
50. A panel can not be added to another panel.
A. True
B. False
C.
D.
Answer : B

Sharing is caring