Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the output produced by the following? String test = abcdefg; System.out.println(test.substring(3)); What is the output produced by the following? System.out.println(abc def); What is

What is the output produced by the following?

String test = "abcdefg"; System.out.println(test.substring(3));

What is the output produced by the following?

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

What is the output produced by the following?

System.out.println("abc\ def");

What is the output produced by the following?

String test = "Hello Tony"; test = test.toUpperCase(); System.out.println(test);

What is the output of the following two lines of Java code?

System.out.println("2 + 2 = " + (2 + 2)); System.out.println("2 + 2 = " + 2 + 2);

The following code is supposed to output the string in lowercase letters but it has an error. What is wrong? How can the code be corrected?

String test = "WHY ARE YOU SHOUTING?"; test.toLowerCase(); System.out.println(test);

Suppose that s1 , s2 , and s3 are three strings, given as follows:

String s1 = "Welcome to Java"; String s2 = "Programming is fun"; String s3 = "Welcome to Java";

What are the results of the following expressions?

s1.charAt(0)

s1.indexOf('j')

s1.indexOf("to")

s1.lastIndexOf('a')

s1.lastIndexOf("o", 15)

s1.length()

s1.substring(5)

s1.substring(5, 11)

s1.toLowerCase()

s1.toUpperCase()

s1.concat(s2)

"\t Wel \t".trim()

Suppose that s1 and s2 are two strings. Which of the following statements or expressions are incorrect?

String s = "Welcome to Java"; String s3 = s1 + s2; String s3 = s1 - s2; s1 == s2; s1 >= s2; s1.compareTo(s2); int i = s1.length(); char c = s1(0); char c = s1.charAt(s1.length());

Show the output of the following statements (write a program to verify your results):

System.out.println("1" + 1); System.out.println('1' + 1); System.out.println("1" + 1 + 1); System.out.println("1" + (1 + 1)); System.out.println('1' + 1 + 1);

Evaluate the following expressions (write a program to verify your results):

1 + "Welcome " + 1 + 1 1 + "Welcome " + (1 + 1) 1 + "Welcome " + ('\u0001' + 1) 1 + "Welcome " + 'a' + 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

5. Describe the visual representations, or models, of communication

Answered: 1 week ago