What does the following code do? String s1 = "805 Martin Street"; String s2 = "805 Martin Street"; if (s1.equals(s2)) { System.out.println("same"); } if (s1 == s2) { System.out.println("equal"); } Question 17Answer a. It prints "equal" and "same" to the console. b. It prints "same" to the console. c. It causes a compile-time error. d. It prints "equal" to the console.
Added by Tammy T.
Step 1
Step 1: The code initializes two String variables, `s1` and `s2`, both containing the same value "805 Martin Street". Show more…
Show all steps
Your feedback will help us improve your experience
Audrey Fong and 69 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Audrey F.
Which statement in C# allows you to do the following: properly check the variable code to determine whether it contains the character $C$, and if it does, display "This is a check" and then advance to a new line? a. if code is equal to $\mathrm{C}$ Console.WriteLine("This is a check"); b. if (code = "C") Console.WriteLine("This is a check"); c. if $\left(\operatorname{code}==^{\prime} C^{\prime}\right)$ Console.WriteLine("This is a check"); d. if $(\operatorname{cod} e==c)$ Console.WriteLine("This is a check"); e. none of the above
Consider the following C code snippet: #include <stdio.h> int main() { char* p = "abc"; char* q = "abc123"; while (*p = *q) { printf("%c%c ", *p, *q); } return 0; } What will our code print when we run the code? Pick one of the choices: a a b b c c a a b b Compilation Error Segmentation Fault
Madhur L.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD