Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions