Home

GRE - Java Programming 1000+ MCQ [Solved] PDF Download

Thursday 9th of March 2023

Sharing is caring

1. 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
2. In RMI before running the client program we must start RMI Registry.
A. True.
B. False.
C.
D.
Answer : A
3. Java always provides a default constructor to a class.
A. True
B. False
C.
D.
Answer : B
4. 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
5. 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
6. 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
7. 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
8. Which of the following represent legal flow control statements?
A. break();
B. continue(inner);
C. return;
D. exit();
Answer : C
9. Any method in a supper class can be over ridden in its subclass.
A. True
B. False
C.
D.
Answer : B
10. JdbcOdbcDriver is an object of Object class
A. True
B. False
C.
D.
Answer : B
11. 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
12. We can add more than one class(es) at the time of compilation Java Beans.
A. True.
B. False.
C.
D.
Answer : A
13. All the bitwise operators have the same level of precedence in Java.
A. True
B. False
C.
D.
Answer : A
14. Which exception is thrown by the read() method of InputStream class?
A. IOException
B. FileNotFoundException
C. ReadException
D. None of the above
Answer : A
15. The length of a string object 's1' can be obtained using the expression s1.length.
A. True
B. False
C.
D.
Answer : B
16. 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
17. 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
18. Submit button always fires doPost(...)
A. True
B. False
C.
D.
Answer : B
19. Connection, Statement are interfaces and ResultSet is a class.
A. True.
B. False.
C.
D.
Answer : B
20. 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
21. 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
22. The setBackground() method is part of the class
A. Applet
B. Component
C. Container
D. Object
Answer : B
23. Which javadoc tag is used to denote a comment for methods parameters?
A. @method
B. @parameter
C. @argument
D. @param
Answer : D
24. 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
25. 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
26. The name of the RMI compiler is ___________
A. rmicom
B. rmic
C. jrmi
D. none of the above
Answer : B
27. 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
28. 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
29. Which of the following represent legal flow control statements?
A. break;
B. break();
C. continue(inner);
D. all of the above
Answer : A
30. It is perfectly legal to refer to any instance variable inside of a static method.
A. True
B. False
C.
D.
Answer : B
31. When we invoke repaint () for a Component, the AWT invokes the method:
A. draw()
B. update()
C. show()
D. paint()
Answer : B
32. 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
33. 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
34. Throwing an exception always causes program termination.
A. True
B. False
C.
D.
Answer : B
35. 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
36. 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
37. Which of the following are not keywords?
A. NULL
B. Implements
C. Protected
D. None of the above
Answer : A
38. 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
39. Which of the following are keywords?
A. integer
B. default
C. Boolean
D. Object
Answer : B
40. Which of the following command lines options generates documentation for all classes and methods?
A. -protected
B. -public
C. -private
D. -encoding
Answer : C
41. Which are the valid ways to create DataInputStream streams?
A. new DataInputStream(new File("in.dat"));
B. new DataInputStream(new FileInputStream("in.dat"));
C. new DataInputStream("in.dat");
D. new DataInputStream("in.data","r");
Answer : B
42. Every call to wait has a corresponding call to notify that will eventually end the wafting.
A. True
B. False
C.
D.
Answer : A
43. 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
44. Servlet has ___________
A. init method
B. doGet(------) method
C. All of the above methods.
D.
Answer : C
45. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
46. 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
47. 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
48. Servlet can have ___________
A. get method and post method
B. get method or post method
C. Either of the above
D.
Answer : C
49. The break statement is required in the default case of a switch selection structure.
A. True
B. False
C.
D.
Answer : B
50. 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

Sharing is caring