J2EEOnline J2EE  

Java Questions 21 - 30  «Prev  Next»

Java Questions 22: Constructors and Data Types

  1. Why can't a constructor be marked static?
    Constructors cannot be marked static because they are associated with instantiation.
  2. Why can't a constructor be marked final?
    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?
    The purpose of a reference variable is to refer to or acces an object.
  4. What type can a reference variable refer to?
    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?
    1. byte - 8
    2. short - 16
    3. int -32
    4. long -64

  6. How can you remember that doubles are larger than floats?
    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?
    Signed means the datatypes are positive or negative.
  8. What do the data types long and double have in common?
    Long and double are both 64 bit.
  9. What are the characteristics of the char data type?
    The char type contains a single, 16-bit Unicode character.
  10. Which two keywords are not allowed to preceed a constructor?
    Constructors cannot be preceeded by the keywords 1) static or 2) final.