+ 5
What will be the output of the following code ??
class Arrays{ public static void main(String args[]){ int a[]={23,34,56,67,99}; int b[]=a; int sum=sumOfArray(b); System.out.println(sum); } static int sumOfArray(int a[]){ int sum=0; for(int i:a){ sum+=i; } return sum; } }
5 ответов
+ 4
Nothing... because you can't inherit from String wich is a final class ^^
+ 4
The output would be the sum of all the elements in array 'a' (since b got it from a), which is 279. I don't quite see anything related to inheriting from String here.
+ 4
@K2 Shape:
The initial post has been edited... Previously the code starting with:
class Arrays extends String {
+ 2
o ok, that was my bad, if it was `class Arrays extends String` then yes, it would output nothing
0
addition of all array of numbers