MCQs > IT & Programming > Java MCQs > Introduction to Java MCQs

Introduction to Java MCQ

Introduction to Java

1. Assigning ____ to a field means that no other classes can access the fields values.

Answer

Correct Answer: Private access

Note: This Question is unanswered, help us to find answer for this one

2. A method can receive ____ arguments, even if it is defined as needing double arguments.

Answer

Correct Answer: Integer

Note: This Question is unanswered, help us to find answer for this one

3. A ________ is a value that signals when the end of a list of values has been reached.

Answer

Correct Answer: Sentinel

Note: This Question is unanswered, help us to find answer for this one

4. When method printf requires multiple arguments, the arguments are separated with ________.

Answer

Correct Answer: Commas (,)

Note: This Question is unanswered, help us to find answer for this one

5. When you instantiate an object from a class, ____ is reserved for each instance field in the class.

Answer

Correct Answer: Memory

Note: This Question is unanswered, help us to find answer for this one

6. The signature of a method consists of ________.

Answer

Correct Answer: Method name and parameter list

Note: This Question is unanswered, help us to find answer for this one

7. The __________ function returns the smallest integer that is greater than or equal to the number.

Answer

Correct Answer: CEILING

Note: This Question is unanswered, help us to find answer for this one

8. The ________ properties are defined in the javafx.scene.text.text class.

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

9. The ________ method is used to display a message dialog.

Answer

Correct Answer: ShowMessageDialog

Note: This Question is unanswered, help us to find answer for this one

10. The ________ loads java bytecode to the memory.

Answer

Correct Answer: Class loader

Note: This Question is unanswered, help us to find answer for this one

11. The ____ method takes a string argument and returns its double value.

Answer

Correct Answer: ParseDouble()

Note: This Question is unanswered, help us to find answer for this one

12. The ____ method converts any object to a string.

Answer

Correct Answer: ToString()

Note: This Question is unanswered, help us to find answer for this one

13. The ____ class represents more serious errors from which your program usually cannot recover.

Answer

Correct Answer: Error

Note: This Question is unanswered, help us to find answer for this one

14. The ____ class provides the definitions for gui objects.

Answer

Correct Answer: Control

Note: This Question is unanswered, help us to find answer for this one

15. When you create an array of objects, each reference is assigned the value ____.

Answer

Correct Answer: Null

Note: This Question is unanswered, help us to find answer for this one

16. The expression ""Java "" + 1 + 2 + 3 evaluates to ________.

Answer

Correct Answer: Java 123

Note: This Question is unanswered, help us to find answer for this one

17. The cookie property is created with a required ____ attribute.

Answer

Correct Answer: Name

Note: This Question is unanswered, help us to find answer for this one

18. The class used as a basis for inheritance is the ____ class.

Answer

Correct Answer: Base

Note: This Question is unanswered, help us to find answer for this one

19. The characters ____ move the cursor to the next line when used within a println() statement.

Answer

Correct Answer: \n

Note: This Question is unanswered, help us to find answer for this one

20. The character class ____ from java.lang.object.

Answer

Correct Answer: Inherits

Note: This Question is unanswered, help us to find answer for this one

21. Static methods can only operate on ________ fields.

Answer

Correct Answer: Static

Note: This Question is unanswered, help us to find answer for this one

22. You use the keyword ________ to reference a method in the superclass from a subclass.

Answer

Correct Answer: Super

Note: This Question is unanswered, help us to find answer for this one

23. You compare two strings s1 and s2 using ________.

Answer

Correct Answer: S1.compareTo(s2

Note: This Question is unanswered, help us to find answer for this one

24. You can use the ________ method to replace an item at a specific location in an arraylist.

Answer

Correct Answer: Set

Note: This Question is unanswered, help us to find answer for this one

25. You can obtain the server's hostname by invoking ________ on an applet.

Answer

Correct Answer: GetCodeBase().getHost()

Note: This Question is unanswered, help us to find answer for this one

26. You can leave out the ____ statements in a switch structure.

Answer

Correct Answer: Break

Note: This Question is unanswered, help us to find answer for this one

27. You can declare two variables with the same name in __________.

Answer

Correct Answer: Different methods in a class

Note: This Question is unanswered, help us to find answer for this one

28. You can create an arraylist using ________.

Answer

Correct Answer: New ArrayList<>()

Note: This Question is unanswered, help us to find answer for this one

29. Whenever a method requires multiple arguments, the arguments are always separated with ____.

Answer

Correct Answer: Commas

Note: This Question is unanswered, help us to find answer for this one

30. Use the ________ method to write text to a web page.

Answer

Correct Answer: Document.new

Note: This Question is unanswered, help us to find answer for this one

31. To use a public variable or method outside of its class, you must ____ the name.

Answer

Correct Answer: Qualify.

Note: This Question is unanswered, help us to find answer for this one

32. To specify a stacking order, one can use the _____ property.

Answer

Correct Answer: Z-index

Note: This Question is unanswered, help us to find answer for this one

33. The __________ method parses a string s to an int value.

Answer

Correct Answer: Integer.parseInt(s);

Note: This Question is unanswered, help us to find answer for this one

34. The __________ method immediately terminates the program.

Answer

Correct Answer: System.exit(0);

Note: This Question is unanswered, help us to find answer for this one

35. The not equal comparison operator in java is ________.

Answer

Correct Answer: !=

Note: This Question is unanswered, help us to find answer for this one

36. To convert a javascript object to a json string, you use the ____ method.

Answer

Correct Answer: Stringify

Note: This Question is unanswered, help us to find answer for this one

37. When an object of one class is a data field within another class, they are related by ____.

Answer

Correct Answer: Composition

Note: This Question is unanswered, help us to find answer for this one

38. Some programmers refer to a catch block as a ____ clause.

Answer

Correct Answer: Clause

Note: This Question is unanswered, help us to find answer for this one

39. Regarding enumerations, the ____ method returns the name of the calling constant object.

Answer

Correct Answer: ToString

Note: This Question is unanswered, help us to find answer for this one

40. Programs that are embedded in a web page are called java ____.

Answer

Correct Answer: Applets

Note: This Question is unanswered, help us to find answer for this one

41. Overloaded methods always have the same _________.

Answer

Correct Answer: Method name

Note: This Question is unanswered, help us to find answer for this one

42. One or more objects may be created from a(n)________.

Answer

Correct Answer: Class

Note: This Question is unanswered, help us to find answer for this one

43. On many keyboards, the break key is also the ____ key.

Answer

Correct Answer: Pause

Note: This Question is unanswered, help us to find answer for this one

44. Methods that set values are called ____ methods.

Answer

Correct Answer: Mutator

Note: This Question is unanswered, help us to find answer for this one

45. Method calls cannot be distinguished by ________.

Answer

Correct Answer: Return type

Note: This Question is unanswered, help us to find answer for this one

46. Local variables must be ________.

Answer

Correct Answer: Initialized before their values are used in expression

Note: This Question is unanswered, help us to find answer for this one

47. Javascript requires _____ programming knowledge and experience as java.

Answer

Correct Answer: The same

Note: This Question is unanswered, help us to find answer for this one

48. Java.util.vector is a subtype of ________.

Answer

Correct Answer: Java.util.AbstractList
Java.util.List

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

49. Java, c#, and vb.net are examples of ________.

Answer

Correct Answer: Object-oriented languages

Note: This Question is unanswered, help us to find answer for this one

50. Java uses class ________ to represent colors using their rgb values.

Answer

Correct Answer: Color

Note: This Question is unanswered, help us to find answer for this one

51. Java contains a class named ____ that allows you to produce dialog boxes.

Answer

Correct Answer: JOptionPane

Note: This Question is unanswered, help us to find answer for this one

52. Java ________ can run from a web browser.

Answer

Correct Answer: Applets

Note: This Question is unanswered, help us to find answer for this one

53. It is important that the loop control ____ be altered within the body of the loop.

Answer

Correct Answer: Variable

Note: This Question is unanswered, help us to find answer for this one

54. Invoking ________ returns the number of the elements in an arraylist x.

Answer

Correct Answer: X.size

Note: This Question is unanswered, help us to find answer for this one

55. Information is passed to a method in ________.

Answer

Correct Answer: The arguments to the method

Note: This Question is unanswered, help us to find answer for this one

56. In pcdata, the ____ symbol is used to indicate a special character.

Answer

Correct Answer: $

Note: This Question is unanswered, help us to find answer for this one

57. In order to allocate the needed memory for an object, you must use the ____ operator.

Answer

Correct Answer: New

Note: This Question is unanswered, help us to find answer for this one

58. In java, you use variables of type ____ to store integers, or whole numbers.

Answer

Correct Answer: Int

Note: This Question is unanswered, help us to find answer for this one

59. In java, ________ must be declared before they can be used.

Answer

Correct Answer: Variables

Note: This Question is unanswered, help us to find answer for this one

60. In java, the word true is ________.

Answer

Correct Answer: A Boolean literal

Note: This Question is unanswered, help us to find answer for this one

61. In java graphics, coordinate units are measured in ________.

Answer

Correct Answer: Pixels.

Note: This Question is unanswered, help us to find answer for this one

62. In java all output uses the ______ data type.

Answer

Correct Answer: String

Note: This Question is unanswered, help us to find answer for this one

63. In a do…while loop, the loop will continue to execute until ____.

Answer

Correct Answer: The loop control variable is false

Note: This Question is unanswered, help us to find answer for this one

64. If you attempt to add an int, a byte, a long, and a float, the result will be a ________ value.

Answer

Correct Answer: Float

Note: This Question is unanswered, help us to find answer for this one

65. If an exception occurs in a try-catch block, the code in the finally clause ________.

Answer

Correct Answer: Is executed

Note: This Question is unanswered, help us to find answer for this one

66. If a programming language does not support ____, the language is not considered object-oriented.

Answer

Correct Answer: Polymorphism

Note: This Question is unanswered, help us to find answer for this one

67. If a key is not in the list, the binarysearch method returns ________.

Answer

Correct Answer: -(insertion point + 1

Note: This Question is unanswered, help us to find answer for this one

68. For input we will use the ______ class.

Answer

Correct Answer: Scanner

Note: This Question is unanswered, help us to find answer for this one

69. Exception handling helps you create ________ programs.

Answer

Correct Answer: Fault-tolerant

Note: This Question is unanswered, help us to find answer for this one

70. Every object is a _____ of a more general class.

Answer

Correct Answer: Member

Note: This Question is unanswered, help us to find answer for this one

71. Every class in java, except ________, extends an existing class.

Answer

Correct Answer: Object

Note: This Question is unanswered, help us to find answer for this one

72. Declaring instance variables ________ is known as data hiding or information hiding.

Answer

Correct Answer: Private

Note: This Question is unanswered, help us to find answer for this one

73. Data items you use in a call to a method are called ____.

Answer

Correct Answer: Arguments

Note: This Question is unanswered, help us to find answer for this one

74. Character literals are enclosed in ________; string literals are enclosed in ________.

Answer

Correct Answer: Single quotes; double quotes

Note: This Question is unanswered, help us to find answer for this one

75. By convention, a class diagram contains the ____ following each attribute or method.

Answer

Correct Answer: Data type

Note: This Question is unanswered, help us to find answer for this one

76. Boolean values can be displayed as the words true and false with the ________ format specifier.

Answer

Correct Answer: %b

Note: This Question is unanswered, help us to find answer for this one

77. Before entering a loop, the first input statement, or ____, is retrieved.

Answer

Correct Answer: Priming read

Note: This Question is unanswered, help us to find answer for this one

78. Arguments to methods always appear within ________.

Answer

Correct Answer: Parentheses

Note: This Question is unanswered, help us to find answer for this one

79. Any field declared with keyword ________ is constant.

Answer

Correct Answer: Final

Note: This Question is unanswered, help us to find answer for this one

80. Another name for a nonstatic member class is a(n) ____.

Answer

Correct Answer: Inner class

Note: This Question is unanswered, help us to find answer for this one

81. A static method can ________.

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

82. A method must declare to throw ________.

Answer

Correct Answer: Unchecked exceptions

Note: This Question is unanswered, help us to find answer for this one

83. A method that has no implementation is called a/an ____ method.

Answer

Correct Answer: Abstract

Note: This Question is unanswered, help us to find answer for this one

84. A method header is also called a(n) _____.

Answer

Correct Answer: Declaration

Note: This Question is unanswered, help us to find answer for this one

85. A loop controlled by the user is a type of ____ loop.

Answer

Correct Answer: Indefinite

Note: This Question is unanswered, help us to find answer for this one

86. A literal string is a(n) ____ object.

Answer

Correct Answer: Anonymous

Note: This Question is unanswered, help us to find answer for this one

87. A javafx action event handler is an instance of ________.

Answer

Correct Answer: EventHandler

Note: This Question is unanswered, help us to find answer for this one

88. A javafx action event handler contains a method ________.

Answer

Correct Answer: Public void handle(ActionEvent e)

Note: This Question is unanswered, help us to find answer for this one

89. A java program is stored in an executable file called a(n) ____ file.

Answer

Correct Answer: Class

Note: This Question is unanswered, help us to find answer for this one

90. A java character is stored in ________.

Answer

Correct Answer: Two bytes

Note: This Question is unanswered, help us to find answer for this one

91. A class specifies the ________ and ________ that a particular type of object has.

Answer

Correct Answer: Fields; methods

Note: This Question is unanswered, help us to find answer for this one

92. A block is enclosed inside ________.

Answer

Correct Answer: Braces

Note: This Question is unanswered, help us to find answer for this one