Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following lines of code below: Evaluate the line marked A. Will this statement compile? If not, explain why. If it does compile, what

Consider the following lines of code below:

Evaluate the line marked A. Will this statement compile? If not, explain why. If it does compile, what is the result?

Evaluate the line marked B. Will this statement compile? If not, explain why. If it does compile, what is the result?

Evaluate the line marked C. Will this statement compile? If not, explain why. If it does compile, what is the result?

Evaluate the line marked D. Will this statement compile? If not, explain why. If it does compile, what is the result?

Evaluate the line marked E. Will this statement compile? If not, explain why. If it does compile, what is the result?

public class VariableScope {

// instance variables - replace the example below with your own

private String tmp;

public String method1()

{

String tmp = "hello"; // A. Evaluate this statement

return tmp;

}

public void method2(String var2)

{

int ctr = 0;

boolean tmp = true; // B. Evaluate this statement

while (tmp)

{

ctr++;

if (ctr > 10)

{

tmp = false;

}

}

}

public void method3(String tmp) // C. Evaluate this statement

{

int ctr = 0;

boolean tmp = true; // D. Evaluate this statement

while (tmp)

{

ctr++;

if (ctr > 10)

{

tmp = false;

}

}

}

public String method4(String tmp)

{

if (tmp.equals("hello"))

{

String tmp = "new value"; // E. Evaluate this statement

return tmp;

}

}

}

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_2

Step: 3

blur-text-image_3

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

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions