you have
public class Question
and
public class MultipleChoice extends Question
and
public class SurveyQuestions
where SurveyQuestions has
private static List<Question> q = new ArrayList<Question>();
In main you keep adding questions and all the things questions are composed of to the list.
Once done, you want to iterate over the list
for (Question q : SurveyQuestions.getInstance().getListOfQuestions())
Question: What type should “q” be so that it has access to both Question and MultipleChoice?
If by “access to” you mean “access to the methods of”- you can’t have it as
MultipleChoicebecause some questions might not be such. So it has to beQuestion, and then you can check if it is a multiple-choice byif(q instanceof MultipleChoice)