This program refreshes your concepts of Core Java and also helps in preparation of SCJP Examination
This program refreshes your concepts of Core Java and also helps in preparation of SCJP Examinationpublic class Example8 {
public static void main(String[] args) {
System.out.println(check(null, 3));
System.out.println(check("hello", 7));
System.out.println(check("bye", 2));
System.out.println(check("hai", 3));
}
public static int check(String a, int n) {
if (n == 7)
return n;
else if (n == 3) {
if (a != null)
return 5;
} else if (n == 5 && a != null) {
if (a.equals("hai"))
return 3;
else if (a.equals("bye"))
return 4;
}
return -3;
}
}
(3)