Home

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

Thursday 9th of March 2023

Sharing is caring

1. We can add more than one class(es) at the time of compilation Java Beans.
A. True.
B. False.
C.
D.
Answer : A
2. The import statement is always the first no comment statement in a Java program files.
A. True
B. False
C.
D.
Answer : B
3. 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
4. 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
5. When we implement an interface method, it should be declared as public.
A. True
B. False
C.
D.
Answer : A
6. Every method of a final in class is implicitly final.
A. True
B. False
C.
D.
Answer : A
7. The default case is always required in the switch selection structure.
A. True
B. False
C.
D.
Answer : B
8. 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
9. Which of the following are keywords?
A. integer
B. default
C. Boolean
D. Object
Answer : B
10. 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
11. 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
12. When X is a positive number the operations x>> 2 and x>>>2 both produce the same result.
A. True
B. False
C.
D.
Answer : A
13. Any class may be inherited by another class in the same package.
A. True
B. False
C.
D.
Answer : B
14. forName() is a static factory method
A. True
B. False
C.
D.
Answer : A
15. 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
16. The check box group class is a subclass of the component class.
A. True
B. False
C.
D.
Answer : B
17. 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
18. 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
19. 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
20. Which of the following are not keywords?
A. NULL
B. Implements
C. Protected
D. None of the above
Answer : A
21. The programmer must explicitly create the system .in and system .out objects.
A. True
B. False
C.
D.
Answer : B
22. 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
23. The keywords reserved but not used in the initial version of Java re:
A. Synchronized
B. Boolean
C. union
D. goto
Answer : D
24. All the bitwise operators have the same level of precedence in Java.
A. True
B. False
C.
D.
Answer : A
25. Which of the following statements are valid array declarations?
A. int number();
B. float average[];
C. double[] marks;
D. counter int[];
Answer : B
26. The modulus operator (%) can be used only with Integer operands.
A. True
B. False
C.
D.
Answer : B
27. 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
28. Message-Driven beans act as a listener for the Java Message Service API, processing messages synchronously
A. True
B. False
C.
D.
Answer : B
29. Which of the following represent legal flow control statements?
A. break;
B. break();
C. continue(inner);
D. all of the above
Answer : A
30. 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
31. When we implement the Runnable interface, we must define the method
A. start()
B. init()
C. runnable()
D. run()
Answer : D
32. Java always provides a default constructor to a class.
A. True
B. False
C.
D.
Answer : B
33. 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
34. 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
35. Which exception is thrown by the read() method of InputStream class?
A. IOException
B. FileNotFoundException
C. ReadException
D. None of the above
Answer : A
36. One the features of is that an array can store many different types of values.
A. True
B. False
C.
D.
Answer : B
37. A package is a collection of
A. classes
B. interface
C. editing tools
D. classes and interfaces
Answer : D
38. A method declared as static can not access non-static class members.
A. True
B. False
C.
D.
Answer : A
39. 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
40. A string object can not be modified after it is created.
A. True
B. False
C.
D.
Answer : A
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. 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
43. 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
44. Which of the following are the wrapper classes?
A. Random
B. Vector
C. Byte
D. all of the above
Answer : C
45. 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
46. Two methods cannot have the same name in Java.
A. True
B. False
C.
D.
Answer : B
47. Servlet has ___________
A. init method
B. doGet(------) method
C. All of the above methods.
D.
Answer : C
48. Objects are passed to a method by use of call-by-reference.
A. True
B. False
C.
D.
Answer : A
49. When we invoke repaint () for a Component, the AWT invokes the method:
A. draw()
B. update()
C. show()
D. paint()
Answer : B
50. class.forName(...) creates an instance of java ODBC driver
A. True
B. False
C.
D.
Answer : A

Sharing is caring