Page 1 of 1

About Question enthuware.ocajp.i.v8.2.897 :

Posted: Sun Dec 02, 2018 5:09 pm
by ghassenkhalil
I didn't understand what's it's asked by this question !

Code: Select all

Given the following code :

public class TestClass {

    int[][] matrix = new int[2][3];
    
    int a[] = {1, 2, 3};
    int b[] = {4, 5, 6};
            
    public int compute(int x, int y){
        //1 : Insert Line of Code here
    }
    
    public void loadMatrix(){
        for(int x=0; x<matrix.length; x++){
            for(int y=0; y<matrix[x].length; y++){
                //2: Insert Line of Code here
            }
        }
    }
}
What can be inserted at //1 and //2?

Re: About Question enthuware.ocajp.i.v8.2.897 :

Posted: Sun Dec 02, 2018 8:47 pm
by admin
The code listing contains two places (marked //1 and //2 ) where you need to insert the code fragments to make the given code listing compile.
Code fragments are given in the options. You have to identify which option makes sense.

Re: About Question enthuware.ocajp.i.v8.2.897 :

Posted: Sat Feb 06, 2021 10:39 am
by aomk_17
admin wrote:
Sun Dec 02, 2018 8:47 pm
The code listing contains two places (marked //1 and //2 ) where you need to insert the code fragments to make the given code listing compile.
Code fragments are given in the options. You have to identify which option makes sense.
The code won't compile with the two member variables having var as their type. Is it just meant to throw us off or was making them var accidental?

Re: About Question enthuware.ocajp.i.v8.2.897 :

Posted: Sat Feb 06, 2021 11:57 am
by admin
You are right. Those should be declared as int[] and not as var. Fixed.
thank you for your feedback!