CS 207 WWC Object Oriented Programming and Data Questions

CS 207 Object-Oriented Programming and DataStructures Lab 3 Fall 2022
Question Given classes Student, Undergrad, and Grad that extend the base class
Student. Build a test driver by creating a class TestStudent and do the following:
1) Create an array of type Student named students with six slots.
2) Create 3 Undergrad objects and store them in the Student array at indices 0-2.
3) Create 3 Grad objects and store them in the Student array at indices 3-5.
4) Create a for loop that dynamically prints the m_code, m_name, and m_level OR
m_thesis (depending on the object type) in the following format.
Sample output:
U, Ana, Junior
U, Gabriel, Senior
U, Sam, Freshman
G, Brian, Structure and Meaning in Word Embedding
G, Xiwei, Machine Learning
G, Cristina, Probability Theory
Reflection Questions
1. Will the following line of code compile after completing step three? Why or why not? If it does
compile, what does it do?
System.out.print(students[1]);
2. Assuming that students[3] references a Grad object, what will the following line
of code do after step three? Why?
System.out.print(((Grad)students[3]).m_id);
Now, change the access modifier of m_id to public. How does that change the output?
What happens if you change it to protected?

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER