Submitted by heartin on Thu, 10/15/2015 - 00:44
Predict the result:
public class NullOverloadCheck {
static void myMethod(Float o)
{
System.out.println("Float");
}
static void myMethod(Integer i){
System.out.println("Integer");
}
public static void main(String[] args)
{
myMethod(null);
}
}
Submitted by heartin on Thu, 10/15/2015 - 00:39
Find the result:
public class NullOverloadCheck {
static void myMethod(Object o)
{
System.out.println("Object");
}
static void myMethod(Integer i){
System.out.println("Integer");
}
public static void main(String[] args)
{
myMethod(null);
}
}
Submitted by heartin on Mon, 09/14/2015 - 10:57
Find output or error:
public class NullCheck {
public void myMethod(String str) {
System.out.println("String");
}
public void myMethod(Double d) {
System.out.println("Double");
}
public static void main(String[] args) {
NullCheck nc = new NullCheck();
nc.myMethod(null);
}
}
Submitted by heartin on Mon, 09/14/2015 - 10:51
Find output or error:
class OOP2 {
int x(double d) {
System.out.println("one");
return 0;
}
String x(double d) {
System.out.println("two");
return null;
}
double x(double d) {
System.out.println("three");
return 0.0;
}
public static void main(String[] args) {
new OOP2().x(4.0)
}
}
Submitted by heartin on Mon, 09/14/2015 - 10:21
Find output or error:
class OOP1 {
void x (int i) {
System.out.println("one");
}
void x (String s) {
System.out.println("two");
}
void x (double d) {
System.out.println("three");
}
public static void main(String[] args) {
new OOP1().x (4.0);
}
}