Home

Java Programming MCQ Solved Paper for CEED

Thursday 9th of March 2023

Sharing is caring

1. Java always provides a default constructor to a class.
A. True
B. False
C.
D.
Answer : B
2. When we invoke repaint () for a Component, the AWT invokes the method:
A. draw()
B. update()
C. show()
D. paint()
Answer : B
3. 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
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. Which of the following classes are available in the java.lang package?
A. Random
B. Stack
C. String Buffer
D. Vector
Answer : A
6. 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
7. All methods in an abstract class must be declared abstract.
A. True
B. False
C.
D.
Answer : B
8. The break statement is required in the default case of a switch selection structure.
A. True
B. False
C.
D.
Answer : B
9. Which of the following represent legal flow control statements?
A. break;
B. break();
C. continue(inner);
D. all of the above
Answer : A
10. The keywords reserved but not used in the initial version of Java re:
A. Synchronized
B. Boolean
C. union
D. goto
Answer : D
11. Two methods cannot have the same name in Java.
A. True
B. False
C.
D.
Answer : B
12. 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
13. 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
14. 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
15. 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
16. 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
17. Any class may be inherited by another class in the same package.
A. True
B. False
C.
D.
Answer : B
18. 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
19. A method declared as static can not access non-static class members.
A. True
B. False
C.
D.
Answer : A
20. Frames and applets cannot be used together in the same program.
A. True
B. False
C.
D.
Answer : B
21. 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
22. 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
23. Connection, Statement are interfaces and ResultSet is a class.
A. True.
B. False.
C.
D.
Answer : B
24. 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
25. Servlet can have ___________
A. get method and post method
B. get method or post method
C. Either of the above
D.
Answer : C
26. JdbcOdbcDriver is an object of Object class
A. True
B. False
C.
D.
Answer : B
27. 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
28. A variable declared inside the for loop control can not be referenced out side the loop.
A. True
B. False
C.
D.
Answer : A
29. 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
30. A static class method can be invoked by simply using the name of the method alone.
A. True
B. False
C.
D.
Answer : B
31. 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
32. The setBackground() method is part of the class
A. Applet
B. Component
C. Container
D. Object
Answer : B
33. 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
34. We can over load methods with differences only in their return type.
A. True
B. False
C.
D.
Answer : B
35. 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
36. Which exception is thrown by the read() method of InputStream class?
A. IOException
B. FileNotFoundException
C. ReadException
D. None of the above
Answer : A
37. 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
38. 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
39. With javadoc, which of the following denotes a javadoc comment?
A. //#
B. /*
C. /**
D. //**
Answer : C
40. One the features of is that an array can store many different types of values.
A. True
B. False
C.
D.
Answer : B
41. 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
42. 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
43. A final class may not have any abstract method.
A. True
B. False
C.
D.
Answer : A
44. 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
45. A class may be both abstract and final.
A. True
B. False
C.
D.
Answer : B
46. A string object can not be modified after it is created.
A. True
B. False
C.
D.
Answer : A
47. 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
48. Declaring a method synchronized guarantees that the deadlock cannot occur.
A. True
B. False
C.
D.
Answer : A
49. Which of the following are the wrapper classes?
A. Random
B. Vector
C. Byte
D. all of the above
Answer : C
50. 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

Sharing is caring