adplus-dvertising
frame-decoration

Question

What is the output of this 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

Posted under Java Programming

Answer: (c).40

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?

Similar Questions

Discover Related MCQs

Q. Which of these is necessary condition for automatic type conversion in Java?

Q. What is the prototype of the default constructor of this class?

public class prototype { }

Q. If an expression contains double, int, float, long, then the whole expression will be promoted into which of these data types?

Q. What is Truncation is Java?

Q. Which of these operators is used to allocate memory to array variable in Java?

Q. Which of these is an incorrect array declaration?

Q. Which of these is an incorrect Statement?

Q. Which of these is necessary to specify at time of array initialization?

Q. Generics does not work with?

Q. How to sort an array?

Q. How to copy contents of array?

Q. Can you make an array volatile?

Q. Where is array stored in memory?

Q. An array elements are always stored in ________ memory locations?

Q. What is the range of short data type in Java?

Q. What is the range of byte data type in Java?

Q. An expression involving byte, int, and literal numbers is promoted to which of these?

Q. Which of these literals can be contained in float data type variable?

Q. Which data type value is returned by all transcendental math functions?

Q. How to format date from one form to another?