quiz 3

quiz 3 - System.out.println(Math.pow(2,4));_______________...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1. Write the output. Import java.util.Random; Public class Quiz3 { Public static void main (String[] args) { String str=”hello”; System.out.println(“abcdef”.substring(1, 3));________________ System.out.println(“pizza”.length( ));_________________ System.out.println(str.replace(‘h’,’m’));________________ System.out.println(“hamburger”.substring(0,3));_______________ System.out.println(str.charAt(1));_________________ System.out.println(str.equals(“hello”));________________ System.out.println(“pizza”.toUpperCase( ));_____________ Random rand = new Random(); Int num1 = rand.nextInt(9); System.out.println(“Write the range for num1? “ + num1);___________ Int num2 = rand.nextInt(9) + 1; System.out.println(“Write the range for num2? “ + num2);____________ Int num3 = rand.nextInt(19) -10; System.out.println(“Write the range for num3? “ +num3);__________
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.println(Math.pow(2,4));_______________ double num4 = Math.sqrt(16); System.out.println(num4);_____________ } } 2. Write the output generated by the following program in the box to the right. Public class TwoStrings { public static void main (String args) String s1 = new String(Clinton, Bill); String s2 = new String(Gore, Al); System.out.println (s1.charAt(2));___________ System.out.println(s1.charAt(s1.length() -1));______________ System.out.println(s2.toUpperCase());________________ System.out.println(s2.substring(s2.indexof( ,) +2, s2.length()));______ } } 3. What value is contained in the integer variable length after the following statements are executed? length = 5; length +=3; length = length *2; 4. What is the result of 2/4 when evaluated in a Java expression.____________ Explain why?...
View Full Document

Page1 / 2

quiz 3 - System.out.println(Math.pow(2,4));_______________...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online