Consider the class that has two instance variables, and These variables are set
ID: 3795917 • Letter: C
Question
Consider the class that has two instance variables, and These variables are set upon creation of an instance of the class via a constructor. Which of the following would define a method that would write out the phrase thrills chills, where the italicized terms are replaced by the contents of the respectively named instance variables. public String writeOut() {return "Filled with: " + this.thrills + " and " + this.chills;} public void writeOut() {System.out.println("Filled with: = + this.thrills + " and " + this. chills);} public String writeOut() {return "Filled with: this.thrills end this.chills";} public void writeOut() {System.out.println("Filled with: thrills and chills");} public void writeOut() {System.out.println("Filled with: this.thrills and this.chills"); >Explanation / Answer
public class OnBoy {
private String thrills;
private String chills;
public OnBoy(String thrils, String chils){
this.thrills = thrils;
this.chills = chils;
}
public void writeOut(){
System.out.println("Filled with: "+this.thrills + " and "+ this.chills);
}
}