1. The name of a Java program fi le must match the name of the class with the extension .java
A. True B. False
2. Two methods cannot have the same name in Java.
A. True B. False
3. The modulus operator (%) can be used only with integer operands.
A. True B. False
4. Declarations can appear anywhere in the body of a Java method.
A. True B. False
5. All the bitwise operators have the same level of precedence in java.
A. True B. False
6. When x is a positive number, the operations x > > 2 and x > > > 2 both produce the same result.
A. True B. False
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
8. In evaluating a logical expression of type
boolean expression1 && boolean expression2
both the boolean expressions are not always evaluated.
A. True B. False
9. In evaluating the expression (x = = y && a < b) the boolean expression x = = y is evaluated fi rst and
then a < b is evaluated.
A. True B. False
10. The default case is always required in the switch selection structure.
A. True B. False
11. The break statement is required in the default case of a switch selection structure.
A. True B. False
12. The expression (x = = y && a < b) is true if ether x = = y is true or a < b is true.
A. True B. False
13. A variable declared inside the for loop control cannot be referenced outside the loop.
A. True B. False
14. Java always provides a default constructor to a class.
A. True B. False
15. When present, package must be the fi rst noncomment statement in the fi le.
A. True B. False
16. The import statement is always the fi rst noncomment statement in a Java program fi le.
A. True B. False
17. Objects are passed to a method by use of call-by-reference.
A. True B. False
18. It is perfectly legal to refer to any instance variable inside of a static method.
A. True B. False
19. When we implement an interface method, it should be declared as public.
A. True B. False
20. We can overload methods with differences only in their return type.
A. True B. False
21. It is an error to have a method with the same signature in both the super class and its subclass.
A. True B. False
22. A constructor must always invoke its super class constructor in its fi rst statement.
A. True B. False
23. Subclasses of an abstract class that do not provide an implementation of an abstract method, are also
abstract.
A. True B. False
24. Any class may be inherited by another class in the same package.
A. True B. False
25. Any method in a super class can be overridden in its subclass.
A. True B. False
26. One of the features of Java is that an array can store many different types of values.
A. True B. False
27. An individual array element that is passed to a method and modifi ed in that method will contain the
modifi ed value when the called method completes execution.
A. True B. False
28. Members of a class specifi ed as a private are accessible only to the methods of the class.
A. True B. False
29. A method declared as static cannot access non-static class members.
A. True B. False
30. A static class method can be invoked by simply using the name of the method alone.
A. True B. False
31. It is an error, if a class with one or more abstract methods is not explicitly declared abstract.
A. True B. False
32. It is perfectly legal to assign an object of a super class to a subclass reference without a cost.
A. True B. False
33. It is perfectly legal to assign a subclass object to a super class reference.
A. True B. False
34. Every method of a fi nal class is implicitly fi nal.
A. True B. False
35. All methods in an abstract class must be declared abstract.
A. True B. False
36. When the String objects are compared with = =, the result is true if the strings contain the same
values.
A. True B. False
37. A String object cannot be modifi ed after it is created.
A. True B. False
38. The length of a String object s1 can be obtained using the expression s1.length.
A. True B. False
39. A catch can have comma-separated multiple arguments.
A. True B. False
40. 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
41. Throwing an Exception always causes program termination.
A. True B. False
42. Every call to wait has a corresponding call to notify that will eventually end the waiting.
A. True B. False
43. Declaring a method synchronized guarantees that the deadlock cannot occur.
A. True B. False
44. The programmer must explicitly create the System.in and System.out objects.
A. True B. False
45. If the fi le-position pointer points to a location in a sequential fi le other than the beginning, we must
use the seek method to bring the pointer to the beginning, to read from the beginning of the fi le again.
A. True B. False
46. To delete a fi le, we can use an instance of class File.
A. True B. False
47. A panel cannot be added to another panel.
A. True B. False
48. Frames and applets cannot be used together in the same program.
A. True B. False
49. A fi nal class may not have any abstract methods.
A. True B. False
50. A class may be both abstract and fi nal.
A. True B. False
51. A thread wants to make a second thread ineligible for execution. To achieve this, the fi rst thread can
call the yield( ) method on the second thread.
A. True B. False
52. A thread can make a second thread ineligible for execution by calling the suspend( ) method on the
second thread.
A. True B. False
53. A Java monitor must either extend Thread class or implement Runnable interface.
A. True B. False
54. The CheckboxGroup class is a subclass of the Component class.
A. True B. False
55. If a frame uses a Grid layout manager and does not contain any panels, then all the components
within the frame are of the same width and height.
A. True B. False
56. With a Border layout manager, the component at the centre gets all the space that is left over, after the
components at North and South have been considered.
A. True B. False
57. The CODE value in an
calling HTML page.
A. True B. False
58. If getParameter( ) returns null, then assigning the return value to a variable of type String may cause
an exception to be thrown.
A. True B. False
59. It is possible to use the File class to list the contents of the current working directory.
A. True B. False
60. Reader class has a method that can read and return fl oats and doubles.
A. True B. False
True/False Questions for java
Tuesday, September 7, 2010
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment