Java - MCQ

Multiple Choice Questions


Share with a Friend

 

Java MCQ - Methods and Arrays - Set 28

1. When does method overloading is determined?
A). At run time
B). At compile time
C). At coding time
D). At execution time
View Answer
Correct: B



2. When Overloading does not occur?
A). More than one method with same name but different method signature and different number or type of parameters
B). More than one method with same name, same signature but different number of signature
C). More than one method with same name, same signature, same number of parameters but different type
D). More than one method with same name, same number of parameters and type but different signature
View Answer
Correct: D



3. What will be the output of the following Java code?

    class average {
        public static void main(String args[])
        {
            double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
            double result;
            result = 0;
            for (int i = 0; i < 6; ++i) 
                result = result + num[i];
            System.out.print(result/6);
 
        } 
    }
A). 16.34
B). 16.566666644
C). 16.46666666666667
D). 16.46666666666666
View Answer
Correct: C



4. What will be the output of the following Java program?

    class array_output {
        public static void main(String args[]) 
        {    
            char array_variable [] = new char[10];
            for (int i = 0; i < 10; ++i) {
                array_variable[i] = 'i';
                System.out.print(array_variable[i] + "" );
                i++;
            }
        } 
    }
A). i i i i i
B). 0 1 2 3 4
C). i j k l m
D). None of the mentioned
View Answer
Correct: A



5. What will be the output of the following Java program?

    class evaluate 
    {
        public static void main(String args[]) 
        {
            int a[] = {1,2,3,4,5};
            int d[] = a;
            int sum = 0;
            for (int j = 0; j < 3; ++j)
                sum += (a[j] * d[j + 1]) + (a[j + 1] * d[j]);
            System.out.println(sum);
        } 
    }
A). 38
B). 39
C). 40
D). 41
View Answer
Correct: C



 
 
 
   
   
   
UltraInfo Technologies
ITDeveloper