Identifiers and Keywords Assignment   Peter Komisar
 



 

Q.1 Which of the following are valid identifiers

 a)  J_1  b) ~rabbit c)  $$__$$78  d)  99Home  e)  _5$_   f) $999   g)  %box

Q2. Which of the following are valid Comments

a)  /* last comment */
b)  //another comment */
c)  /** and another
d)  //comment

Q3  Which of the following are valid keywords

a) continue b) default  c) instanceOf   d) Int  e) cases  g)  if   h) break  i) imports  j) package

Q4  T/F
      i) The number of people living in Hamilton can be represented by a variable of type short
      ii) The number of people in the world can be represented by variable of type long
      iii) The product, 12 times 11 can be represented by a variable of type byte.
      iv) The estimated number of cubic centimeters in the universe can be represented by a
           variable of type float

Q5  Look at the String class summary on in van der Linden at page 101. If a string was
created as follows String s= "mississippi" and a method on s was called as follows.
s=s.replace('s','p'); What would System.out.println(s); print to screen? Would this be an
example of the string first represented at s being modified ? [You might have to check
the API documentation or some other source to get a description of the replace( ) method]