Question: 1. What will be the result of this code? Alien[] aliens = new Alien[20]; aliens[0].setName(Ali Baba); System.out.println(aliens[0].getName()); Assume that setName and getName work properly. A.

1. What will be the result of this code?

Alien[] aliens = new Alien[20]; aliens[0].setName("Ali Baba"); System.out.println(aliens[0].getName()); 

Assume that setName and getName work properly.

A. Ali Baba
B. None of these are correct.
C. Nothing
D. NullPointerException

2. Assuming the following code:

int minIdx = 0;//index to the youngest person int maxIdx = 0; //index to the oldest person for (int i = 1; i < people.length; i++) { if ( people[i].getAge() < people[minIdx].getAge() ) { minIdx = i; //found a younger person } else if (people[i].getAge() > people[maxIdx].getAge() ) { maxIdx= i; //found an older person } }//people[minIdx] is the youngest & people[maxIdx] is the oldest 

If every person in a given array of people were the same age, then the first person in the array would be both the youngest and oldest person in the array.

A. True

B. False

3. Which of the following methods is most likely an example of method overriding?

Alien a = new Alien(); a.setName("Ali Baba"); a.setAge(40); a.encryptInformation(); System.out.println(a.toString()); 

A. setAge

B. toString

C. encryptInformation

D. setName

4. In passing an array to a method, the value of the argument is copied to the parameter.

A. True

B. False

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!