Home

Java Programming MCQ Solved Paper for LIC ADO

Thursday 9th of March 2023

Sharing is caring

1. Throwing an exception always causes program termination.
A. True
B. False
C.
D.
Answer : B
2. 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
3. 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
4. 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
5. 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
6. DriverManager.getConnection("jdbc:odbc:dsn_name") method does not depend on the class.forName(...) method.
A. True.
B. False.
C.
D.
Answer : B
7. A thread can make second thread ineligible for execution by calling the suspend (-) method on second thread.
A. True
B. False
C.
D.
Answer : A
8. 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
9. To delete a file, we can use an instance of class file.
A. True
B. False
C.
D.
Answer : A
10. 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
11. 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
12. Which of the following represent legal flow control statements?
A. break();
B. continue(inner);
C. return;
D. exit();
Answer : C
13. 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
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. In RMI we invoke client method from remote server
A. True
B. False
C.
D.
Answer : B
16. When we invoke repaint () for a Component, the AWT invokes the method:
A. draw()
B. update()
C. show()
D. paint()
Answer : B
17. Which of the following methods belong to the String class?
A. length()
B. compareTo()
C. substring()
D. all of the them
Answer : D
18. 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
19. A constructor must always invoke its supper class constructor in its first statement.
A. True
B. False
C.
D.
Answer : B
20. 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
21. Connection, Statement are interfaces and ResultSet is a class.
A. True.
B. False.
C.
D.
Answer : B
22. A final class may not have any abstract method.
A. True
B. False
C.
D.
Answer : A
23. Java always provides a default constructor to a class.
A. True
B. False
C.
D.
Answer : B
24. 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
25. Two methods cannot have the same name in Java.
A. True
B. False
C.
D.
Answer : B
26. 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
27. 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
28. 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
29. The import statement is always the first no comment statement in a Java program files.
A. True
B. False
C.
D.
Answer : B
30. 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
31. Which of the following are keywords?
A. integer
B. default
C. Boolean
D. Object
Answer : B
32. 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
33. A static class method can be invoked by simply using the name of the method alone.
A. True
B. False
C.
D.
Answer : B
34. With javadoc, which of the following denotes a javadoc comment?
A. //#
B. /*
C. /**
D. //**
Answer : C
35. A variable declared inside the for loop control can not be referenced out side the loop.
A. True
B. False
C.
D.
Answer : A
36. Objects are passed to a method by use of call-by-reference.
A. True
B. False
C.
D.
Answer : A
37. 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
38. It is perfectly legal to assign a subclass object to a supper class reference.
A. True
B. False
C.
D.
Answer : A
39. The keywords reserved but not used in the initial version of Java re:
A. Synchronized
B. Boolean
C. union
D. goto
Answer : D
40. All the bitwise operators have the same level of precedence in Java.
A. True
B. False
C.
D.
Answer : A
41. 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
42. Servlet can have ___________
A. get method and post method
B. get method or post method
C. Either of the above
D.
Answer : C
43. 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
44. forName() is a static factory method
A. True
B. False
C.
D.
Answer : A
45. 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
46. 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
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. 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
49. 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
50. Any class may be inherited by another class in the same package.
A. True
B. False
C.
D.
Answer : B

Sharing is caring