ExamVeda
Login
Home
Data Types and Variables
?

Determine output:
public class Test {
        static void test(float x){
                System.out.print("float");
        }

        static void test(double x){
                System.out.print("double");
        }

        public static void main(String[] args){
                test(99.9);
        }
}

Answer & Solution
Correct Answer: Option B

floating-point numbers are by default of type double.
99.9 is a double not a float.
To print "float" cast 99.9 to (float)

Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Meenal Oswal
Meenal Oswal 10 years ago
Please explain this solution