0% found this document useful (0 votes)
8 views4 pages

Java MCQs 51 To 100

Uploaded by

sweth8706
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Java MCQs 51 To 100

Uploaded by

sweth8706
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Java MCQs (Q.51 - Q.

100)

51. Java HTML doc


1) java HTML doc 2) Javadoc 3) jar 4) java C

52. The Java compiler generates code in


1) Byte code 2) OP - code 3) Machine-language 4) assembly language

53. If the member variable of a class is to be shared by all the objects that class, it should be
declared
1) volatile 2) public 3) final 4) static

54. The statement System.out.println(-34>>2);


1) prints -36 2) prints -136 3) prints 136 4) prints -9

55. Which of the following statements is valid?


statement 1 : float m1 = 2.1;
statement 2 : double m2 = 2.1;
statement 3 : long m3 = 2.1;
1) statement 1 & 2 2) statement 2 3) statement 3 4) none

56. Which of the following operator work with variables but not literals?
(A) + (pre - increment) (B) ++ (post - inc) (C) >>
1) A and B 2) A only 3) C only 4) D

57. The statements int m = 9, n= 5, p =3;


System.out.println((m-n*n%p > (m*n%p)) ? "prints op": "prints zero");
1) prints true 2) prints op 3) prints false 4) prints non-zero

58. Which of the following is not a keyword in Java?


1) Super 2) Volatile 3) this 4) pointer

59. The statement _______ can be replaced by the statement


1) this 2) super 3) ... 4) ...

60. Which of the following can be declared final


(A) A class (B) A method (C) A member variable
1) A and B 2) A and C 3) All the above 4) None

61. Which of the following cannot be used as identifier?


1) Letter 2) Digits 3) underscores 4) spaces

62. The concept of multiple inheritance is implemented in Java by


1) extending two or more classes 2) extending one class and implementing one or more interfaces
3) implementing two or more interfaces 4) Both 2 and 3

63. 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?
1) private 2) protected 3) private OR protected 4) public

64. Which of the following are valid statements


1) public class MyCalc extends Math 2) Math.max(S);
3) Math.round(9.99,1); 4) None of the above.
65. Which of the following are true?
1) The Void class extends the Class class. 2) The Float class extends the Double class.
3) The System class extends the Runtime class. 4) The Integer class extends the Number class.

66. Which of the following classes is used to perform basic console I/O?
1) System 2) SecurityManager 3) Math 4) Runtime

67. Which of the following methods cause the String object referenced by s to be changed?
1) s.concat() 2) s.toUpperCase() 3) s.replace() 4) both 1 and 3

68. Which of the following is true?


1) wait(), notify(), notifyAll() are defined as final & can be called only from within a synchronized
method
2) Among wait(), notify(), notifyAll() the wait() method only throws IOException
3) wait(), notify(), notifyAll() & sleep() are methods of object class
4) All the above

69. What is the mechanism defined by java for the Resources to be used by only one Thread at a
time?
1) Synchronisation 2) Catch 3) Wait 4) None

70. If you do not implement all the methods of an interface while implementing , what specifier
should you use for the class?
1) abstract 2) instance class 3) interface 4) none

71. Which are keywords in Java?


1) NULL 2) extends 3) synchronized 4) both 2 and 3

72. Identify the true statements about finalization.


1) A class may have only one finalize method 2) Finalizers are mostly used with simple classes
3) Finalizers are not implicitly called 4) both 1 and 2

73. Which of the following operators are used in conjunction with the this and super references?
1) The new operator 2) The instanceof operator 3) The dot operator 4) none of the above

74. When must the main class and the file name coincide?
1) When class is declared public. 2) When class is declared private
3) When class is declared protected 4) All of the above

75. When may a constructor be called without specifying arguments?


1) When the default constructor is not called 2) When the name of the constructor differs from that
of the class
3) When there are no constructors for the class 4) When a parameterized constructor is called

76. What are the functions of the dot(.) operator?


1) It enables you to access instance variables of any objects within a class
2) It enables you to store values in instance variables of an object
3) It is used to call object methods 4) All the above

77. Which of the following statements can be used to describe a public method?
1) It is accessible to all other classes in the hierarchy
2) It is accessible only to subclasses of its parent class
3) It represents the public interface of its class
4) Both 1 and 3

78. What is the result of expression 5.45 + "3,.2"?


79. The String "8.4567" has a double value
1) 8.6 2) The string 3) The long value of 13.3 4) The result of (3/4)

80. You would use the ___ operator to create a single instance of a named class.
1) new 2) dot 3) equal to 4) none of the above

81. You can explicitly drop an object reference by setting the value of a variable whose data type is
1) pre-defined type 2) Object 3) Null 4) None of the above

82. What are all the methods available in Thread class


1) start() 2) join() 3) resume() 4) suspend()

83. Which of the following statements correctly describes Java?


1) It is a correct class 2) It is a superclass 3) It is a subclass 4) None of the above

84. All the classes of packages can be simultaneously imported using


1) import package.*; 2) import class.*; 3) import package; 4) import this.*;

85. When will your program wish to run the garbage collector?
1) before it enters a memory-intensive section of code
2) before it terminates
3) before it enters a critical section of code
4) all the above

86. Which of the following types of class members can part of the internal part of a class?
1) static variables 2) instance variables 3) methods 4) both 1 and 2

87. Which of the following are legal methods of the Math class?
1) max() 2) abs() 3) round() 4) All the above

88. Which of the following are legal methods of the String class?
1) length() 2) compareTo() 3) equals() 4) All the above

89. What happens when you compile and run the following code?
Integer ten = new Integer(10);
Long nine = new Long (9);
System.out.println(ten + nine);
int i = 1;
System.out.println(i + ten);

1) 19 followed by 11 2) 19 followed by 11.0 3) Compilation error 4) None of the above

90. The four protected variables and methods in a class allows the following visibilities as follows:
1) Visible only in the same class and subclasses in the same package
2) Visible only in the same class and subclasses in other packages
3) Visible only in the same package
4) Visible only in the subclasses where package is declared.

91. Package P1 contains the following code:


public class Student

1) Class result should be declared public.


2) Test class is not available.
3) Student class is not available.
4) Result body is not fully defined.
92. Which of the following are keywords?
1) switch & default 2) integer & byte 3) Boolean 4) object & class

93. Consider the following code:


interface Area

1) Method compute() in class Room should be declared public


2) Interface definition is incomplete
3) Method compute() in interface Area should be declared public
4) All of these

94. Which of the following will output -4.0?


1) System.out.println(Math.floor(-4.7));
2) System.out.println(Math.round(-4.7));
3) System.out.println(Math.ceil(-4.7));
4) System.out.println(Math.Min(-4.7));

95. Which of the following methods are methods of the String class?
1) delete() 2) append() 3) reverse() 4) replace()

96. What is the method available for setting the priority?


1) getPriority() 2) setPriority() 3) Both 1 and 2 4) none

97. What is an example of polymorphism?


1) Inner class 2) Anonymous classes 3) Method overloading 4) Method overriding

98. Which of the following can be referenced by this variable?


1) The instance variables of a class only
2) The methods of a class only
3) The instance variables and methods of a class
4) none of the above

99. Which method is used to garbage collect an object?


1) finalize() 2) get() 3) throw() 4) sleep()

100. (End of Practice Set)

You might also like