齐鲁工业大学
  1. Every method’s body is delimited by left and right braces ({ and }). ( )

  2. A:对 B:错
    答案:对
  3. By convention, method names begin with an uppercase first letter, and all subsequent words in the name begin with a capital first letter. ( )

  4. A:错 B:对
    答案:错
  5. Primitive-type local variables are initialized by default. ( )

  6. A:错 B:对
    答案:错
  7. An import declaration is not required when one class in a package uses another in the same package. ( )

  8. A:对 B:错
    答案:对
  9. ( )

  10. A:A, B and C are overloaded
    B:All four methods are overloaded
    C:A and B are overloaded; C and D are overloaded
    D:A and C are overloaded; B and D are overloaded

    答案:All four methods are overloaded
  11. Which of the following operators associates from left to right? ( )

  12. A:=
    B:/
    C:%=
    D:?:

    答案:/
  13. When an object is concatenated with a String, ________. ( )

  14. A:a runtime error occurs
    B:the object’s toString method is implicitly called to obtain the String representation of the object
    C:a compilation error occurs
    D:the object’s class name is concatenated with the String

    答案:the object’s toString method is implicitly called to obtain the String representation of the object
  15. Class Arrays provides method __________ for comparing arrays to determine whether they have the same contents. ( )

  16. A:compare
    B:equal
    C:equals
    D:compares

    答案:equals
  17. Which of the following class members should usually be private? ( )

  18. A:Variables (or fields).
    B:Constructors.
    C:Methods.
    D:All of the above.

    答案:Variables (or fields).
  19. For the array that was the correct answer in the previous question, what is the value returned by items[1][0]? ( )

  20. A:8.
    B:12.
    C:4.
    D:6.
  21. Which operator can be used in string concatenation? ( )

  22. A:++
    B:*
    C:=+
    D:+=
  23. Which of the following does not complete the sentence correctly?Interface ______ . ( )

  24. A:can be instantiated.
    B:forces classes that implement it to declare all the abstract interface methods.
    C:is declared in a file by itself and is saved in a file with the same name as the interface followed by the .java extension.
    D:can be used in place of an abstract class when there is no default implementation to inherit.
  25. What is output by the following Java code segment?
    ( )

  26. A:This porridge is too hot! This porridge is just right!
    B:None of the above.
    C:This porridge is just right!
    D:This porridge is too cold! This porridge is just right!
  27. Counter-controlled repetition is also known as: ( )

  28. A:Indefinite repetition
    B:Double-repetition structure
    C:Definite repetition
    D:Multiple-repetition structure
  29. Which of the following primitive types is never promoted to another primitive type? ( )

  30. A:double.
    B:byte.
    C:boolean.
    D:Both a and c.
  31. Which of the following statements is false? ( )

  32. A:Use the access modifier package to give a method or variable package access.
    B:Classes in the same source file are part of the same package.
    C:If a program uses multiple classes from the same package, these classes can access each other's package access members directly through references to objects of the appropriate classes, or in the case of static members, through the class name.
    D:Package access is rarely used.
  33. Portions of statements that contain calculations are called ( )

  34. A:variables.
    B:constants.
    C:expressions.
    D:None of the above.
  35. What is output by the following Java code segment?
    ( )

  36. A:This porridge is too cold.
    This porridge is just right!
    B:This porridge is too hot.
    C:None of the above.
    D:This porridge is just right!
  37. Which of the following statements is false? ( )

  38. A:When a class implements an interface, the class receives the interface’s default concrete implementations if it does not override them.
    B:When you enhance an existing interface with default methods—any class that implemented the original interface will break.
    C:With default methods, you can declare common method implementations in interfaces (rather than abstract classes), which gives you more flexibility in designing your classes.
    D:In Java SE 8, an interface may declare default methods—that is, public methods with concrete implementations that specify how an operation should be performed.
  39. Declaring instance variables ________ is known as data hiding or information hiding. ( )

  40. A:static
    B:secure
    C:masked
    D:private
  41. Which of the following is not a Java primitive type? ( )

  42. A:real
    B:double
    C:char
    D:byte
  43. Having a this reference allows: ( )

  44. A:All of the above.
    B:a method to refer explicitly to the instance variables and other methods of the object on which the method was called.
    C:an object to reference itself.
    D:a method to refer implicitly to the instance variables and other methods of the object on which the method was called.
  45. Attempting to access an array element outside of the bounds of an array, causes a(n) . ( )

  46. A:ArrayException.
    B:ArrayElementOutOfBoundsException.
    C:ArrayIndexOutOfBoundsException.
    D:ArrayOutOfBoundsException.
  47. Identifiers in Java have ________ and ________ scopes? ( )

  48. A:method, class.
    B:block, statement.
    C:statement, file.
    D:class, block.
  49. When method printf requires multiple arguments, the arguments are separated with ________. ( )

  50. A:semicolons (;).
    B:commas (,).
    C:colons (:).
    D:periods (.).
  51. An argument type followed by a(n) _______ in a method’s parameter list indicates that the method receives a variable number of arguments of that particular type. ( )

  52. A:varargs keyword
    B:All of the above are acceptable to indicate a variable number of arguments.
    C:square brackets ([])
    D:ellipsis (...)
  53. Which of the following statements is true? ( )

  54. A:Package java.lang is imported in every Java program.
    B:All of the above are true.
    C:System.out.print("Enter your age: "); prompts the user to take action.
    D:Class names typically begin with a capital letter.
  55. The static method ________ of class String returns a formatted String. ( )

  56. A:format.
    B:formatString.
    C:toFormatedString.
    D:printf.
  57. Which of the following will not help prevent infinite loops? ( )

  58. A:Include braces around the statements in a do…while statement.
    B:If the loop is counter-controlled, the body of the loop should increment or decrement the counter as needed.
    C:If the loop is sentinel-controlled, ensure that the sentinel value is input eventually.
    D:Ensure that the header of a for or while statement is not followed by a semicolon.
  59. Polymorphism allows for specifics to be dealt with during: ( )

  60. A:programming.
    B:execution.
    C:compilation.
    D:debugging.
  61. The format specifier %.2f specifies that two digits of precision should be output ________ in the floating-point number. ( )

  62. A:None of the above.
    B:centered
    C:to the right of the decimal point
    D:to the left of the decimal point
  63. When a subclass constructor calls its superclass constructor, what happens if the superclass’s constructor does not assign a value to an instance variable? ( )

  64. A:A run-time error occurs.
    B:A syntax error occurs.
    C:The program compiles and runs because the instance variables are initialized to their default values.
    D:A compile-time error occurs.
  65. Which of these statements best defines scope? ( )

  66. A:Scope determines whether a variable’s value can be altered.
    B:Scope is the portion of a program that can refer to an entity by its simple name.
    C:Scope refers to the classes that have access to a variable.
    D:Scope allows the programmer to use a class without using its fully qualified name.
  67. In an expression containing values of the types int and double, the ________ values are ________ to ________ values for use in the expression. ( )

  68. A:int, promoted, double.
    B:double, demoted, int.
    C:int, demoted, double.
    D:double, promoted, int.
  69. Sentinel-controlled repetition is also known as ________. ( )

  70. A:Double repetition
    B:Multiple repetition
    C:Definite repetition
    D:Indefinite repetition
  71. Which of the following statements is true? ( )

  72. A:Information hiding is achieved by restricting access to class members via keyword public.
    B:Methods and instance variables can both be either public or private.
    C:The private members of a class are directly accessible to the clients of a class.
    D:None of the above is true.
  73. A(n) ________ indicates a problem that occurs while a program executes. ( )

  74. A:missing semicolon
    B:exception
    C:syntax error
    D:omitted import
  75. Which statement best describes the relationship between superclass and subclass types? ( )

  76. A:A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.
    B:A superclass reference can be assigned to a subclass variable, but a subclass reference cannot be assigned to a superclass variable.
    C:A subclass reference cannot be assigned to a superclass variable and a superclass reference cannot be assigned to a subclass variable.
    D:A subclass reference can be assigned to a superclass variable and a superclass reference can be assigned to a subclass variable.
  77. Local variables must be ________. ( )

  78. A:initialized before their values are used in an expression.
    B:declared and initialized in two steps.
    C:initialized when they're declared.
    D:declared at the top of the method’s body.
  79. Which of the following promotions of primitive types is not allowed to occur? ( )

  80. A:short to long.
    B:int to double.
    C:char to int.
    D:double to float.
  81. Which command below runs TestProgram, and passes in the values files.txt and 3? ( )

  82. A:java TestProgram files.txt 3.
    B:java TestProgram files.txt, 3.
    C:None of the above.
    D:java TestProgram "files.txt", "3".
  83. Invalid possibilities for array indices include . ( )

  84. A:Zero.
    B:None of the above.
    C:Positive integers.
    D:Negative integers.
  85. Where can local variables declared within a method’s body be used? ( )

  86. A:Only in that method between the line in which they were declared and the closing brace of that method.
    B:Same as (a), but not within while or if statements.
    C:Only within while or if statements within the method in which they were declared.
    D:Anywhere within the class.
  87. Which of the following statements is false? ( )

  88. A:If a method does not return a value, the return-value-type in the method declaration can be omitted.
    B:Redeclaring a method parameter as a local variable in the method’s body is a compilation error.
    C:Placing a semicolon after the right parenthesis enclosing the parameter list of a method declaration is a syntax error.
    D:Forgetting to return a value from a method that should return a value is a compilation error.
  89. Which of the following is not possible? ( )

  90. A:All of the above are possible.
    B:A class that inherits from one class, and implements an interface.
    C:A class that implements two interfaces.
    D:A class that inherits from two classes.
  91. Which of the following statements is false? ( )

  92. A:Class Collections contains many static helper methods for working with objects that implement interfaces Collection, List, Set and more.
    B:With non-static interface methods, helper methods can now be declared directly in interfaces rather than in separate classes.
    C:Prior to Java SE 8, it was common to associate with an interface a class containing static helper methods for working with objects that implemented the interface.
    D:Collections method sort can sort objects of any class that implements interface List.
  93. What is the result value of c at the end of the following code segment?int c = 8;c++;++c;c %= 5;( )

  94. A:None of the above.
    B:3.
    C:0.
    D:1.
  95. Static class variables: ( )

  96. A:are shared by all objects of a class.
    B:are public.
    C:are private.
    D:are final.
  97. Which statement is true when a superclass has protected instance variables? ( )

  98. A:Subclass methods are more likely to be written so that they depend on the superclass’s data implementation.
    B:We may need to modify all the subclasses of the superclass if the superclass implementation changes.
    C:All of the above.
    D:A subclass object can assign an invalid value to the superclass’s instance variables, thus leaving an object in an inconsistent state.
  99. Which expression is equivalent to if (!(grade == sentinelValue))? ( )

  100. A:! if (grade !== sentinelValue)
    B:if (grade !== sentinelValue)
    C:if (grade != sentinelValue)
    D:! if (grade == sentinelValue)

温馨提示支付 ¥5.00 元后可查看付费内容,请先翻页预览!
点赞(1) dxwkbang
返回
顶部