Home

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

Thursday 9th of March 2023

Sharing is caring

1. We can over load methods with differences only in their return type.
A. True
B. False
C.
D.
Answer : B
2. Members of a class specified as private are accessible only to the methods of the class.
A. True
B. False
C.
D.
Answer : A
3. 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
4. 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
5. Which of the following represent legal flow control statements?
A. break;
B. break();
C. continue(inner);
D. all of the above
Answer : A
6. A string object can not be modified after it is created.
A. True
B. False
C.
D.
Answer : A
7. Submit button always fires doPost(...)
A. True
B. False
C.
D.
Answer : B
8. In RMI we invoke client method from remote server
A. True
B. False
C.
D.
Answer : B
9. Which exception is thrown by the read() method of InputStream class?
A. IOException
B. FileNotFoundException
C. ReadException
D. None of the above
Answer : A
10. Servlet has ___________
A. init method
B. doGet(------) method
C. All of the above methods.
D.
Answer : C
11. It is perfectly legal to assign a subclass object to a supper class reference.
A. True
B. False
C.
D.
Answer : A
12. 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
13. The import statement is always the first no comment statement in a Java program files.
A. True
B. False
C.
D.
Answer : B
14. DriverManager.getConnection("jdbc:odbc:dsn_name") method does not depend on the class.forName(...) method.
A. True.
B. False.
C.
D.
Answer : B
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. class.forName(...) creates an instance of java ODBC driver
A. True
B. False
C.
D.
Answer : A
17. Which of the following command lines options generates documentation for all classes and methods?
A. -protected
B. -public
C. -private
D. -encoding
Answer : C
18. The setBackground() method is part of the class
A. Applet
B. Component
C. Container
D. Object
Answer : B
19. It is perfectly legal to refer to any instance variable inside of a static method.
A. True
B. False
C.
D.
Answer : B
20. Connection, Statement are interfaces and ResultSet is a class.
A. True.
B. False.
C.
D.
Answer : B
21. 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
22. 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
23. The modulus operator (%) can be used only with Integer operands.
A. True
B. False
C.
D.
Answer : B
24. Which of the following are not keywords?
A. NULL
B. Implements
C. Protected
D. None of the above
Answer : A
25. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
26. Java always provides a default constructor to a class.
A. True
B. False
C.
D.
Answer : B
27. 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
28. 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
29. The check box group class is a subclass of the component class.
A. True
B. False
C.
D.
Answer : B
30. Throwing an exception always causes program termination.
A. True
B. False
C.
D.
Answer : B
31. The name of the RMI compiler is ___________
A. rmicom
B. rmic
C. jrmi
D. none of the above
Answer : B
32. Which of the following are keywords?
A. integer
B. default
C. Boolean
D. Object
Answer : B
33. Objects are passed to a method by use of call-by-reference.
A. True
B. False
C.
D.
Answer : A
34. Any class may be inherited by another class in the same package.
A. True
B. False
C.
D.
Answer : B
35. In RMI before running the client program we must start RMI Registry.
A. True.
B. False.
C.
D.
Answer : A
36. Two methods cannot have the same name in Java.
A. True
B. False
C.
D.
Answer : B
37. Servlet can have ___________
A. get method and post method
B. get method or post method
C. Either of the above
D.
Answer : C
38. A panel can not be added to another panel.
A. True
B. False
C.
D.
Answer : B
39. Message-Driven beans act as a listener for the Java Message Service API, processing messages synchronously
A. True
B. False
C.
D.
Answer : B
40. 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
41. 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
42. 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
43. 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
44. 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
45. 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
46. All the bitwise operators have the same level of precedence in Java.
A. True
B. False
C.
D.
Answer : A
47. 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
48. 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
49. 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
50. Java is fully object oriented programme.
A. true
B. false
C.
D.
Answer : A

Sharing is caring