Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (ellecullen):

Homework help asap please: The equals method from the String class returns true if two strings contain the same characters, even if they refer to two different strings. true or false?

OpenStudy (bibby):

``` public class HelloWorld{ public static void main(String []args){ String a = "abc"; String b = "cde"; String c = "abc"; System.out.println(a==b); System.out.println(a==c); System.out.println(a.equals(c)); } } ``` the output of this program is: false true true

OpenStudy (ellecullen):

but what about the question? is the answer true or false? :)

OpenStudy (bibby):

System.out.println(a.equals(c)); evaluated to true a and c are different strings you tell me

OpenStudy (ellecullen):

so the answer is true I think. Also, Iwanted some help with another 2 questions : 1. a subordinate statement inside a while loop must always be inside braces. (True or false? just the overall answer) 2. see the coding: public void toggleCDs() { while (seesSlot()){ if (seesCD()) takeCD(); else putCD(); moveOn(); } } //======================= what would be the correct output if args = "101010" ? Assume the arm is at the beginning of the sequence.

OpenStudy (bibby):

no idea about the f irst one, post the full code on the 2nd

OpenStudy (ellecullen):

Here is the full code: public class whatever { public void toggleCDs() { while (seesSlot()){ if (seesCD()) takeCD(); else putCD(); moveOn(); } } //======================= in the application, it is public static void main (String[ ] args) { Vic sue; sue = new Vic(); sue.toggleCDs();

OpenStudy (ellecullen):

can you hand draw the out put for me please?

OpenStudy (bibby):

I have no idea what seesCDs() does, this isn't the full code

OpenStudy (ellecullen):

it means that if the vic sees the slot, and if it sees the CD it takes it . I found the online pdf of the book : http://www.cs.ccsu.edu/~jones/chap03.pdf site http://www.cs.ccsu.edu/~jones/book.htm

OpenStudy (harsha19111999):

@woodrow73

OpenStudy (anonymous):

righy

OpenStudy (ellecullen):

Thanks :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!