Question: Find the error in each of the following program segments. Explain how to correct the error. a) void g() { System.out.println(Inside method g); void h()
Find the error in each of the following program segments. Explain how to correct the error.
a)
void g() {
System.out.println("Inside method g");
void h() {
System.out.println("Inside method h");
}
}
b)
int sum(int x, int y) {
int result;
result = x + y;
}
c)
void f(float a); {
float a;
System.out.println(a);
}
d)
void product() {
int a = 6;
int b = 5;
int c = 4;
int result = a * b * c;
System.out.printf("Result is %d%n", result);
return result;
}
Step by Step Solution
3.46 Rating (162 Votes )
There are 3 Steps involved in it
a Error The method returns a value when its not supposed to Correctio... View full answer
Get step-by-step solutions from verified subject matter experts
