A program stores Character class object instances in a list. The Character class
ID: 3907124 • Letter: A
Question
A program stores Character class object instances in a list. The Character class contains a public "Age" property. After the first list is populated with 10000 references, a second list is allocated and assigned the references from the first list. The second list's element at index 2000 is accessed and the character's age is changed from "O" to "99." The first list is sorted then accessed at index two thousand with the character's age written to the Console What will be display to the user? O 99 O Maybe 0, maybe 99, maybe some other value... no way to predict what will be displayed Null reference error O Out of range error O Inaccessible due to protection level NothingExplanation / Answer
Answer:
0,assuming list was sorted by age property with def Val 0.
I assuming all 10000 references were new objects, so they all had def value of age 0. When u sort a list of 10000 objects by age, only 1 of them had age 99, it will move to either start or end of list, depending if the list is ascending or descending. Either case, the index 2000 no longer has age 99, but age 0. Both lists here are essentially the same since we're copying class object references. The only diff is, list 1 has references sorted in order and 2 has not. Regardless, outcome is the same.
DEAR PLEASE DO RATE IT IF HELPS ELSE LET ME KNOW YOUR DOUBT.
KINDLY POST SEPARATELY AS WE ARE RESTRICTED TO ANSWER MORE THAN ONE QUESTION FROM MULTIPLE POSTED QUESTIONS.
THANK YOU!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.