Consider the following line of code for calling a method named methodX where d a
ID: 3704270 • Letter: C
Question
Consider the following line of code for calling a method named methodX where data is an integer and varData is an double variable.
methodX (data, varData );
Which one of the following method headers is valid for methodX?
public static void methodX ( int varData, double data)
The non-static methods of a class are called the ____ methods of the class.
permanent
Which of the following is an example of a local identifier in the following code?
01: public class scopeRule
02: {
03: static double intRate = 0.055;
04: static String name;
05: static int t;
06: public static int main(String[] args)
07: {
08: int first;
09: double u, t;
10: String str;
11: //. . .
12: }
13: public static int first(int x, int y)
14: {
15: int t;
16: }
17: public static double salary;
18: }
Which of the following identifiers in the following code are usable in method first?
01: public class scopeRule
02: {
03: private double intRate = 0.055;
04: private static String name;
05: private int t;
06: public static int main(String[] args)
07: {
08: int first;
09: double u, t;
10: String str;
11: //. . .
12: }
13: public static int first(int x, int y)
14: {
15: int t;
16: }
17: public double salary;
18: }
name (Line 4)
Which of the following identifiers in the following code are usable in another class?
01: public class scopeRule
02: {
03: private double intRate = 0.055;
04: private static String name;
05: private int t;
06: public static int main(String[] args)
07: {
08: int first;
09: double u, t;
10: String str;
11: //. . .
12: }
13: public static int first(int x, int y)
14: {
15: int t;
16: }
17: public double salary;
18: }
intRate (Line 3)
In the method first, the programmer wishes to update the value stored in the variable intRate (Line 3). Which of the following is correct?
01: public class scopeRule
02: {
03: private double intRate = 0.055;
04: private String name;
05: private static int t;
06: public static int main(String[] args)
07: {
08: int first;
09: double u, t;
10: String str;
11: //. . .
12: }
13: public static int first(int x, int y)
14: {
15: double intRate;
16: intRate = x * y;
17: }
18: public double salary;
19: }
Consider the following class definition.
public class Cylinder extends Object {
private double height;
public Cylinder (double radius, double h) {
super(radius);
height = h;
}
public double getRadius() {
return super.getRadius();
}
public String toString() {
return (getRadius() + " " + height);
}
public double surfaceArea() {
return 2 * 3.14 * getRadius() * height;
}
public double volume() {
return 3.14 * getRadius() * getRadius() * height;
}
}
Suppose that you have the following declaration.
Cylinder cyl = new Cylinder(1.5, 10);
Which of the following statements are valid in Java?
None are correct.Explanation / Answer
Question 1
Answer:
public static void methodX ( int varData, double data)
Question 2
Answer:
instance
Question 3
Answer:
int t;
Question 4
Answer:
name (Line 4)
Question 5
Answer:
salary (Line 17)
Question 6
Answer:
Write another non-static method to do so.
Question 7
Answer:
cyl.volume();
cyl.surfaceArea();
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.