J2EEOnline J2EE   





Java Questions 21 - 30  «Prev  Next»

Java Questions 22: Constructors and Data Types

  1. Why can't a constructor be marked static?
    Answer:
    Constructors cannot be marked static because they are associated with instantiation.
  2. Why can't a constructor be marked final?
    Answer:
    Constructors are not inherited so they can't be overridden, so what is the use of having a final constructor.
  3. What is the purpose of a reference variable?
    Answer:
    The purpose of a reference variable is to refer to or acces an object.
  4. What type can a reference variable refer to?
    Answer:
    A reference variable can be used to refer to any object of the declared type, or of a subtype of the declared type (a compatible type).
  5. For integer types, what is the sequence from small to large?
    Answer:
    1. byte - 8
    2. short - 16
    3. int -32
    4. long -64
  6. How can you remember that doubles are larger than floats?
    Answer:
    A double is twice the number of bits as a float (32 X 2 = 64) bits.
    [byte - 8, short - 16, int -32, long - 64, float -32, double -64]
  7. What does it mean when datatypes are signed?
    Answer:
    Signed means the datatypes are positive or negative.
  8. What do the data types long and double have in common?
    Answer:
    Long and double are both 64 bit.
  9. What are the characteristics of the char data type?
    Answer:
    The char type contains a single, 16-bit Unicode character.
  10. Which two keywords are not allowed to preceed a constructor?
    Answer:
    Constructors cannot be preceeded by the keywords 1) static or 2) final.