Consider the following Java if expression: if ( done.equalsIgnoreCase(“yes”) ) &
ID: 3859184 • Letter: C
Question
Consider the following Java if expression:
if ( done.equalsIgnoreCase(“yes”) ) && n != 10 )
{
y = k.readWord( );
}
else
{
done = z;
}
Use the context in the above code to determine the data type of the following variables and declare them below.
____ done;
_____ n;
_____ y;
_____ k;
_____ z;
Explanation / Answer
String done;
done is compared with a String so it must be a String
int n;
n is compared with integer so it must be an integer
String y;
readWord() returns a String so y must be a String
MyReader k= new MyReader(Filename);
k is the inputstream associated with the Filename. MyReader is eg a class to read from file
String z;
z is assigned a String so it must be a String
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.