What is the output of the following JAVA program ?
class simple { public static void main(String[ ] args) { simple obj = new simple( ); obj.start( ); } void start( ) { long [ ] P= {3, 4, 5}; long [ ] Q= method (P); System.out.print (P[0] + P[1] + P[2]+”:”); System.out.print (Q[0] + Q[1] + Q[2]); } long [ ] method (long [ ] R) { R [1]=7; return R; } } //end of class
(A) 12 : 15
(B) 15 : 12
(C) 12 : 12
(D) 15 : 15
Answer: (D)
Explanation: When above program compliled and run on ide then it will produce 15:15.
IDE link
Option (D) is correct.
Quiz of this Question
Article Tags :
Recommended Articles