beginner to Java
Good evening,
I am taking a class in Java, and need help answering the following 2
questions. Any help will be greatly appreciated.
Question 6: I can't make ends meet with this question. I have read the
chapter back and forth, but i don't understand where to dissect the
question.
public class ScopeRules // line 1
{
static final double rate=10.50;
static int z;
static double t;
public static void main(String[]args) // line 7
{
int num;
double x, z;
char ch;
// main block...
}
public static void one(int f, char g) // line 15
{
// block one...
}
public static int w; // line 20
public static void two(int one,int i) // line 22
{
char ch;
int a;
//block three
{
int x = 12; // line 29
//...
}//end block three
// block two... // line 32
}
}
Which of the following identifiers is visible in method one? rate
(before main)
local variables of method two
x (block three's local variable)
one (method two's formal parameter)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Question 17
I don't understand what the term "S" is suppose to define. If lastinitial
is suppose to be S, than would it default to Section 5, since S is not a
case study. Please clarify.
switch(lastInitial)
{
case 'A': System.out.println("section 1");
break;
case 'B': System.out.println("section 2");
break;
case 'C': System.out.println("section 3");
break;
case 'D': System.out.println("section 4");
break;
default: System.out.println("section 5");
}
Based on the code above, what is the output if lastInitial = 'S'?
section 2
section 3
section 4
section 5
Thanx again.
Alvin
begin 666 spacer.gif
M1TE&.#EA!0`'`( ``/___P```"'Y! $`````+ `````%``<```(%A(^INP4`
!.P``
`
end