Home

1000+ Java Programming MCQ for ESIC [Solved]

Thursday 9th of March 2023

Sharing is caring

1. class.forName(...) creates an instance of java ODBC driver
A. True
B. False
C.
D.
Answer : A
2. 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
3. We can add more than one class(es) at the time of compilation Java Beans.
A. True.
B. False.
C.
D.
Answer : A
4. Which of the following statements are valid array declarations?
A. int number();
B. float average[];
C. double[] marks;
D. counter int[];
Answer : B
5. 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
6. The setBackground() method is part of the class
A. Applet
B. Component
C. Container
D. Object
Answer : B
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. The name of the RMI compiler is ___________
A. rmicom
B. rmic
C. jrmi
D. none of the above
Answer : B
9. 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
10. 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
11. 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
12. Two methods cannot have the same name in Java.
A. True
B. False
C.
D.
Answer : B
13. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
14. 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
15. Which of the following classes are available in the java.lang package?
A. Random
B. Stack
C. String Buffer
D. Vector
Answer : A
16. A variable declared inside the for loop control can not be referenced out side the loop.
A. True
B. False
C.
D.
Answer : A
17. For all insert, update, delete, query operations on a database, ResultSet object creation is mandatory.
A. True.
B. False.
C.
D.
Answer : B
18. 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
19. A panel can not be added to another panel.
A. True
B. False
C.
D.
Answer : B
20. Every call to wait has a corresponding call to notify that will eventually end the wafting.
A. True
B. False
C.
D.
Answer : A
21. 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
22. All methods in an abstract class must be declared abstract.
A. True
B. False
C.
D.
Answer : B
23. When we implement an interface method, it should be declared as public.
A. True
B. False
C.
D.
Answer : A
24. A method declared as static can not access non-static class members.
A. True
B. False
C.
D.
Answer : A
25. Submit button always fires doPost(...)
A. True
B. False
C.
D.
Answer : B
26. Which of the following are not keywords?
A. NULL
B. Implements
C. Protected
D. None of the above
Answer : A
27. Which of the following methods belong to the String class?
A. length()
B. compareTo()
C. substring()
D. all of the them
Answer : D
28. 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
29. 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
30. The keywords reserved but not used in the initial version of Java re:
A. Synchronized
B. Boolean
C. union
D. goto
Answer : D
31. One the features of is that an array can store many different types of values.
A. True
B. False
C.
D.
Answer : B
32. The default case is always required in the switch selection structure.
A. True
B. False
C.
D.
Answer : B
33. Frames and applets cannot be used together in the same program.
A. True
B. False
C.
D.
Answer : B
34. Which javadoc tag is used to denote a comment for methods parameters?
A. @method
B. @parameter
C. @argument
D. @param
Answer : D
35. 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
36. 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
37. Which of the following are keywords?
A. integer
B. default
C. Boolean
D. Object
Answer : B
38. 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
39. 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
40. The programmer must explicitly create the system .in and system .out objects.
A. True
B. False
C.
D.
Answer : B
41. Connection, Statement are interfaces and ResultSet is a class.
A. True.
B. False.
C.
D.
Answer : B
42. Any class may be inherited by another class in the same package.
A. True
B. False
C.
D.
Answer : B
43. Members of a class specified as private are accessible only to the methods of the class.
A. True
B. False
C.
D.
Answer : A
44. 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
45. A catch can have comma-separated multiple arguments.
A. True
B. False
C.
D.
Answer : B
46. With javadoc, which of the following denotes a javadoc comment?
A. //#
B. /*
C. /**
D. //**
Answer : C
47. 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
48. Java is fully object oriented programme.
A. true
B. false
C.
D.
Answer : A
49. When present, package must be the first no comment statement in the file.
A. True
B. False
C.
D.
Answer : A
50. forName() is a static factory method
A. True
B. False
C.
D.
Answer : A

Sharing is caring