Question: Consider the following class file. What does the method methodA output? public class Test 1 { private String str 1 = hello; public Test 1

Consider the following class file. What does the method "methodA" output?
public class Test1
{
private String str1="hello";
public Test1()
{
String str1="goodbye";
}
public void methodA()
{
System.out.println(str1);
}
}
5. Suppose you have a method called "methodA" to which you pass 2 floats. It returns a String. Show
how to call this method and assign the String it returns into the String variable str1. Assume the
method is in the same class that you are calling it from.
6. Consider the following code where an int variable is passed to a method. The method changes the
value of its parameter then returns. Is the value changed when you return from the method call? If not,
why not?
int i=1;
changeInt(i);
System.out.println("i="+i);
...
public void changeInt(int i)
{
i=5;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!