

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


String s1 = new String(“\tWorld!\n”); String s2 = “Hello”; s3 = s1; System.out.println(“s3: ” + s3); s1 = s2 + s1; System.out.println(“s3: ” + s3); System.out.println(“Length of s1: ” + s1.length()); System.out.println(“Substring: ” + s1.substring(3, 6));
Not correct! Variable s3 should be declared as: String s3 = s1;
s3: World! s3: World! Length of s1: 13 Substring: lo
import java.util.Random;
Random generator = new Random(); int randomNumber; randomeNumber = 1+generator.nextInt(5); System.out.println( "num1 is " + randomeNumber); randomeNumber = 2 * generator.nextInt(9) - 4; System.out.println( "num2 is " + randomeNumber);
randomeNumber = 3 * generator.nextInt(13) - 5;
1Qu
"); double fahrenheit = scan.nextDouble( ); double celsius = (5.0/9.0)*(fahrenheit-32) ; System.out.println("Your temperature in Celsius is " + celsius); } }