CS670K Homework Set 1 - Fall 1998

Due: Thursday, September 24

© Copyright University of New Haven 1998

class C
{
        static int i= 1;
        int j= 2;
        final static int k= 3;
        float f= 1.2f;
        Integer n= new Integer(5);
        Float x= new Float(9.8);
        String s= "-4";

        public static void main(String arg[])
        {
                C c= new C();

                c.i= 9;  c.j= -2;

//		Each question goes here...
        }
}
Evaluate each of the following statements INDEPENDENTLY OF THE OTHERS, (that is IGNORE THE EFFECT OF PRECEDING QUESTIONS), and give the output or put ERROR as appropriate.
  1. System.out.println( 1+2, 3 );
  2. System.out.println( i= k );
  3. System.out.println( k= i );
  4. System.out.println( c.i= Integer.parseInt(c.s) );
  5. System.out.println( c.s+= 1+2 );
  6. System.out.println( c.s + "0.5" );
  7. System.out.println( c.f + new Float(c.s).floatValue() );
  8. System.out.println( c.x + s.valueOf(c.f) );
  9. System.out.println( c.x.floatValue() - c.i );
  10. System.out.println( c.x + c.s );
Home Page