Question: Identify the error in the programs and write a corrected code: 1. public class Test{ public static method1(int n , m){ n += m; method2(3.4);
Identify the error in the programs and write a corrected code:
1. public class Test{
public static method1(int n , m){
n += m;
method2(3.4);
} // end of method 1
public static method2(int n){
if(n > 0){
return 1;
}
else if(n == 0){
return 0;
}
else if(n < 0){
return -1;
}
} // end of method 2
} // end of class
2.
| public class TestPrint{ public static void main (String[] args){ nPrintln(5, "welcome to Java!"); } // end of main
public static nPrintln (String msg, int n){ for(int i=0; i System.out.println(msg); } } // end of nPrintln } // end of class |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
