---
# System prepended metadata

title: Afride Iqubal

---

# Afride Iqubal

# Question 1: Find the 2nd largest number in an integer array.
```java=

public static void main(String args[]){
    int arr[] = {6,8,2,4,3};
    int largest =Integer.MIN_VAlUE;
    INT secondLargest = Integer.MIN_VALUE;
    for(int i=0;i<arr.length;i++){
        if(arr[i] > largest)
            {
                secondLargest = largest;
                largest = arr[i];
            }
//         else if (arr[i] == largest && arr[i] == secondLargest)
//         {
            
//         }
        else if(arr[i] > secondLargest && arr[i] != largest)
        {
            secondLargest = arr[i];
        }
        
    }
    if(secondLargest == Integer.MIN_VAlUE)
    {
        System.out.println("Not Found Second Largest Element");
    }
    else {
        System.out.println(secondLargest);
    }
}





```

# Question 2: Js transformation

```javascript=
const arrObj = [
    { age: 10, name: 'A', class: 5},
    { age: 12, name: 'B', class: 5},
    { age: 10, name: 'C', class: 5},
    { age: 12, name: 'D', class: 6},
    { age: 11, name: 'E', class: 6},
    { age: 12, name: 'F', class: 7}
]



// print all students names in class 6

// let obj = [];
let AllStudentName5 = arrObj.filter((s)=> s.class === 5).map((e)=>e.name);
console.log(AllStudentName);
let AllStudentName6 = arrObj.filter((s)=> s.class === 6).map((e)=>e.name);
console.log(AllStudentName);
let AllStudentName7 = arrObj.filter((s)=> s.class === 7).map((e)=>e.name);
console.log(AllStudentName);
 var result = {};
for(var i = 0; i<arrObj.length;i++){
    var Std = arrObj[i].class;
    if(`$(std}` in result)
        {
//             append the AllStudentName5 ,6 and 7
        }
    else
        {
            object.assign(result `[arrObj[i].class]`)
        }
}


// {
//     5: ['A', 'B', 'C'],
//     6: ['D', 'E'],
//     7: ['F']
// }

// empty Object, iterative over the ArrObj
```

