JAVA From 8 to 14 pleases 8. What is the difference between the two comparison s
ID: 3720450 • Letter: J
Question
JAVA
From 8 to 14 pleases
8. What is the difference between the two comparison statements below? What is each condition actually comparing? String s2 = new String ("Arthur"); String s4new String ("Arthur") System.out.printin(s2-s4); System.out.println(s2.equals(s4)): 9. Write code that will compare the two Strings below for equality based on their value and print the message "equals" or "not equals". String s1"Apple" String s2"Banana"; 10. When are two reference variables aliases? Provide an example with Strings 11. Consider the two classes below. Which is the more general / specialized? Superclass / subclass? public class Foo) public class FooChild extends Foo 12. Write the WidgetChild class. It is a subclass of the Widget class in problem 1. The WidgetChild has an additional instance variable, int x a. Include a constructor that requires input b. Include getters and setters c. Add a toString() method to the WidgetChild class to print all the information about a WidgetChild. Use the overriden toString() method of the Widget class 13. Create a WidgetChild object. methods of WidgetChild Using the getters of the class and dot notation, run all theExplanation / Answer
8 Answer) False
True
9 Answer)
if(s1.equal(s2)){
System.out.println("equals");
}else{
System.out.println("not equals");
}
10 Answer)
When two variables reference the same memory location, it is called aliasing
String s1 ="Apple";
String s2=s1;//s2 also refers the same memory location as s1
11 Answer)
Foo - Superclass/general
FooChild - Subclass/specialized
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.