Quiznetik

Java Programming | Set 5

1. Java is designed for _______ environment of the internet.

Correct : C. distributed.

2. ______ is a small unit of a process.

Correct : B. thread.

3. Wrapper class is a wrapper around a _______ data type.

Correct : C. primitive.

4. Once an interface has been defined, one or more _____ can implement that interface.

Correct : A. class.

5. Variable declared as _________ do not occupy memory on a per instance basis.

Correct : B. final.

6. ______ must be the first statement executed inside a subclass Constructor.

Correct : B. super().

7. The ________ connects classes and objects.

Correct : A. dot.

8. The ________ statement is used to terminate a statement sequence.

Correct : A. break.

9. Multidimensional arrays are actually __________.

Correct : C. arrays of arrays.

10. ______ statement in java is multiway branch statement.

Correct : D. switch.

11. _______ can be declared inside interface declarations.

Correct : A. Variables.

12. The _______ supports several constructors to create an empty String.

Correct : B. super class.

13. __________ is used for initialize the value to the String object.

Correct : B. string literals.

14. ____ operators which concatenates two strings.

Correct : A. +.

15. _______ method is a thread mechanism.

Correct : A. synchronize.

16. Java programs are _________ independent.

Correct : A. platform.

17. A java program can be run in any computer running under any ________.

Correct : A. operating system.

18. A java program must contain a______ method.

Correct : B. main.

19. Which of these class holds a collection of static methods and variables?.

Correct : D. System.

20. _________ operator is used to create an array.

Correct : A. new .

21. Which of these class is used to create an object whose character sequence is mutable?.

Correct : B. StringBuffer().

22. The variable defined in class is called ________ variable.

Correct : C. instance.

23. A special type of method that is used to initialize an object is called________.

Correct : A. constructor.

24. Class is considered ________ of an object and instance.

Correct : C. template.

25. String constants are said to be_____ of string class.

Correct : A. objects.

26. Methods having same name and differ type signature are called _____methods.

Correct : D. overloading.

27. Methods having same name, same type signature are called _____ methods.

Correct : A. overriding.

28. A method without the body is called ________ method.

Correct : C. abstract.

29. A class having an abstract method is to be declared as _______.

Correct : B. abstract.

30. Package statement helps to create many classes to have ______ name.

Correct : C. same.

31. The default package that is implicitly called in a java program is _________.

Correct : A. java.Lang.

32. User defined exception can be created using _________ class.

Correct : C. throwable.

33. Which of these keywords is not a part of exception handling?.

Correct : C. thrown.

34. Exception that is identified during compile time is called ______ exception.

Correct : B. checked.

35. When several tasks are handled by a single CPU, it is called _________.

Correct : A. multitasking.

36. Threads can be created by extending _________ class.

Correct : C. thread.

37. Threads can be created by implementing ________ interface.

Correct : D. runnable.

38. When a thread is created using new operator, the thread is in _____ state.

Correct : A. new.

39. At any one instance of time _____ threads will be in running state.

Correct : D. one.

40. Which of these classes are used by character streams for input and output operations?.

Correct : B. Writer.

41. The wrapper classes are defined in _________ packages.

Correct : B. java. Lang.

42. The capacity if StringBuffer is defined as _________.

Correct : D. Length+16.

43. To compare the contents of two objects ______ method is used.

Correct : A. equals.

44. Which of these class is used to read from byte array?.

Correct : D. ByteArrayInputStream.

45. Graphics object can only be drawn on _________.

Correct : B. windows.

46. What is byte code in the context of Java?

Correct : A. The type of code generated by a Java compiler.

47. What is garbage collection in the context of Java?

Correct : C. When all references to an object are gone, the memory used by the object is~~~automatically reclaimed.

48. What output is displayed as the result of executing the following statement?System.out.println ("// Looks like a comment.");

Correct : C. Looks like a comment.

49. In order for a source code file, containing the public class Test, to successfully compile, which of the following must be true?

Correct : B. It must be named Test.java.

50. What is the value of a [3] as the result of the following array declaration?

Correct : D. 4.

51. Which of these data tupe can be used for a method having a return statement in it?.

Correct : D. All of the mentioned.

52. What is an example of polymorphism?

Correct : C. method overloading.

53. An interface contains __________ methods.

Correct : C. unimplemented.

54. Which of the following is not a wrapper class?

Correct : A. string.

55. Which of these is the method which is executed first before execution of any other thing takes place in a program?.

Correct : C. static method.

56. Which of the following methods are methods of the String class?

Correct : D. replace( ).

57. If you run the code below, what gets printed out?String s=new String ("Bicycle"); int iBegin=1; char iEnd=3; System.out.println (s.substring (iBegin, iEnd));

Correct : B. ic.

58. Given the following declarations String s1=new String("Hello") ; String s2=new String("there"); String s3=new String(); Which of the following are legal operations?

Correct : A. s3=s1 + s2;.

59. Which of the following classes is used to perform basic console I/O?

Correct : A. system.

60. Which of these keywords is used to define packages in Java?,

Correct : C. package.

61. Which of the following are true about the Error and Exception classes?

Correct : A. Both classes extend Throwable.

62. Which of the following are true?

Correct : D. The Integer class extends the Number class.

63. Which of the following will output -4.0?

Correct : C. System.out.println(Math.ceil(-4.7));.

64. What is the default return type to main() __________.

Correct : D. int.

65. Which of the following statements are true?

Correct : D. Unicode characters are all 16-bits.

66. You execute the code below in an empty directory. What is the result? File f1 = new File ("dirname");F ile f2 = new File (f1, "filename");

Correct : C. A new file called filename is created in the current working directory.

67. How do you create a Reader object from an InputStream object?

Correct : C. Create an InputStreamReader object, passing the InputStream object as an argument to the InputStreamReader constructor.

68. How can you change the current working directory using an instance of the File class called FileName?

Correct : D. The File class does not support directly changing the current directory.

69. Which of these is a mechanism for naming and visibility control of a class and its content?.

Correct : B. Packages.

70. Which of the following is correct way of importing an entire package named as pkg?.

Correct : C. import pkg.*.

71. Which of these is correct way of calling a constructor having no parameters, of superclass A by subclass B?.

Correct : D. super();.

72. Suppose A is an abstract class ,B is a concrete subclass of A, and both A and B have an default constructor. Which of the following is correct? a) A a = new A(); b)A a = new B(); c) B b = new A(); d) B b = new B();

Correct : B. Both b & d.

73. Which of the following declares an abstract method in an abstract Java class?

Correct : B. public abstract void method();.

74. Which of these keywords are used to define an abstract class?.

Correct : B. abstract

75. Which of these is not a correct statement?.

Correct : C. Abstract class can be initiated by new operator.

76. Which of the following statements about the try{} block in Java is false?

Correct : C. The try{} block cannot contain loops or branches.

77. The concept of multiple inheritance is implemented in Java by ____ (i.) extending two or more classes (ii.) extending one class and implementing one or more interfaces (iii.) implementing two or more interfaces (iv.) all of these

Correct : D. (ii) & (iii) only

78. What is polymorphism in Java? .

Correct : D. It is when a class has several methods with the same name but different parameter types.

79. What code would you use to construct a 24-point bold serif font?

Correct : B. new Font("SERIF", Font.BOLD,24);.

80. A / An ________ variable is shared by all instances of the class. It exists even before an object is created.

Correct : A. instance

81. The concept of derived classes is involved in _________.

Correct : C. polymorphism.

82. Which of these keywords is used by a class to use an interface defined previously?.

Correct : C. implements.

83. super keyword can be used to _____.

Correct : C. both a and b.

84. Overloaded methods ___.

Correct : A. are a group of methods with the same name.

85. ____ are automatically called when an object is destroyed.

Correct : C. finalize().

86. ___ keyword is used to refer to the current object.

Correct : B. this.

87. When a class is declared as final , then ____.

Correct : A. It can not be inherited

88. When method is overridden , then by subclass object which class method is called _____.

Correct : A. super class.

89. Before doing garbage collection , _____ method is called .

Correct : B. finalize().

90. The .dot operator connects the following two entities _____.

Correct : A. a class member and a class object

91. Which layout should you use to organize the components of a container in a tabular~~~form?

Correct : D. Grid Layout.

92. An Applet has its Layout Manager set to the default of FlowLayout. What code~~~would be the correct to change to another Layout Manager?

Correct : B. setLayout(new GridLayout(2,2));.

93. How do you indicate where a component will be positioned using Flowlayout?

Correct : D. Do nothing, the FlowLayout will position the component.

94. How do you change the current layout manager for a container?

Correct : A. Use the setLayout method.

95. Which of the following may contain a menu bar?

Correct : B. A frame.

96. What will be the content of array variable table after executing the following code? for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (j == i) { table[i][j] = 1; } else { table[i][j] = 0; } } }

Correct : C. 1 0 0 0 1 0 0 0 1.

97. Which of the following classes are not available in the java.lang package?

Correct : A. Stack.

98. Which of the following are not the wrapper classes?

Correct : C. Integer.

99. Which of the following method is not belonging to the String class?

Correct : B. reverse().

100. If not assigned a value, a variable of type char has the following default value:

Correct : B. \u0000'.