Home

Java Programming 1000+ MCQ with answer for LIC AAO

Thursday 9th of March 2023

Sharing is caring

1. Members of a class specified as private are accessible only to the methods of the class.
A. True
B. False
C.
D.
Answer : A
2. Any class may be inherited by another class in the same package.
A. True
B. False
C.
D.
Answer : B
3. 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
4. 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
5. 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
6. Which of the following methods belong to the String class?
A. length()
B. compareTo()
C. substring()
D. all of the them
Answer : D
7. 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
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. 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
10. Throwing an exception always causes program termination.
A. True
B. False
C.
D.
Answer : B
11. 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
12. class.forName(...) creates an instance of java ODBC driver
A. True
B. False
C.
D.
Answer : A
13. 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
14. We can add more than one class(es) at the time of compilation Java Beans.
A. True.
B. False.
C.
D.
Answer : A
15. 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
16. A class may be both abstract and final.
A. True
B. False
C.
D.
Answer : B
17. 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
18. In RMI we invoke client method from remote server
A. True
B. False
C.
D.
Answer : B
19. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
20. Which of the following represent legal flow control statements?
A. break();
B. continue(inner);
C. return;
D. exit();
Answer : C
21. The default case is always required in the switch selection structure.
A. True
B. False
C.
D.
Answer : B
22. The programmer must explicitly create the system .in and system .out objects.
A. True
B. False
C.
D.
Answer : B
23. 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
24. 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
25. The check box group class is a subclass of the component class.
A. True
B. False
C.
D.
Answer : B
26. 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
27. 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
28. 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
29. 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
30. A package is a collection of
A. classes
B. interface
C. editing tools
D. classes and interfaces
Answer : D
31. The modulus operator (%) can be used only with Integer operands.
A. True
B. False
C.
D.
Answer : B
32. JdbcOdbcDriver is an object of Object class
A. True
B. False
C.
D.
Answer : B
33. Which of the following are not keywords?
A. NULL
B. Implements
C. Protected
D. None of the above
Answer : A
34. When we invoke repaint () for a Component, the AWT invokes the method:
A. draw()
B. update()
C. show()
D. paint()
Answer : B
35. Any method in a supper class can be over ridden in its subclass.
A. True
B. False
C.
D.
Answer : B
36. Java is fully object oriented programme.
A. true
B. false
C.
D.
Answer : A
37. A static class method can be invoked by simply using the name of the method alone.
A. True
B. False
C.
D.
Answer : B
38. It is perfectly legal to assign a subclass object to a supper class reference.
A. True
B. False
C.
D.
Answer : A
39. It is perfectly legal to refer to any instance variable inside of a static method.
A. True
B. False
C.
D.
Answer : B
40. 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
41. Java always provides a default constructor to a class.
A. True
B. False
C.
D.
Answer : B
42. One the features of is that an array can store many different types of values.
A. True
B. False
C.
D.
Answer : B
43. A string object can not be modified after it is created.
A. True
B. False
C.
D.
Answer : A
44. 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
45. forName() is a static factory method
A. True
B. False
C.
D.
Answer : A
46. 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
47. 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
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. When we implement an interface method, it should be declared as public.
A. True
B. False
C.
D.
Answer : A
50. The name of the RMI compiler is ___________
A. rmicom
B. rmic
C. jrmi
D. none of the above
Answer : B

Sharing is caring