Question: Code fragment Printed value System.out.println( 7 / 2.0 ); System.out.println( 7 / 2 ); System.out.println( 7 % 2 ); System.out.println( 0 / 2 ); System.out.println(

Code fragment

Printed value

System.out.println( 7 / 2.0 );

System.out.println( 7 / 2 );

System.out.println( 7 % 2 );

System.out.println( 0 / 2 );

System.out.println( 1 / 2 );

System.out.println( 12 / 2 * 2 );

System.out.println( 12 / (2 * 2) );

System.out.println( 12 / 2 / 2 );

System.out.println( 1 + 2 / 3 + 4 );

System.out.println( (0 + 11) / 12 );

System.out.println( (1 + 11) / 12 );

System.out.println( (2 + 11) / 12 );

System.out.println( (10 + 11) / 12 );

System.out.println( (11 + 11) / 12 );

System.out.println( (12 + 11) / 12 );

System.out.println( (13 + 11) / 12 );

String and String Methods

For the code fragments below where the variable str is initialized to "abcde", give the printed values for each of the println statements.

String str = "abcde";

Printed value

System.out.println( str );

System.out.println( str.charAt( 0 ) );

System.out.println( str.charAt( 1 ) );

System.out.println( str.charAt( 2 ) );

System.out.println( str.length( ) );

System.out.println( "abc".length( ) );

System.out.println( str.substring( 0, 1 ) );

System.out.println( str.substring( 1 ) );

System.out.println( str.toUpperCase( ) );

System.out.println( str.indexOf( "c" ) );

System.out.println( str.equals( "abcde" ) );

System.out.println( "abcde".equals( str ) );

System.out.println( "a".length( )/2);

System.out.println( "abc".length( )/2);

System.out.println( "abcde".length( )/2);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!