Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java programming question (Object oriented programming) Answer FULL question properly for thumbs up: Question 2 (a) A programmer decides to use Java instead of C

Java programming question (Object oriented programming)

Answer FULL question properly for thumbs up:

image text in transcribed

Question 2 (a) A programmer decides to use Java instead of C in a project, partly because "errors are handled better and debugging is easier". With reference to the features and the programming environments of both languages, explain why the programmer might have arrived at this conclusion (b) The programmer in (a) notes that her main reason for choosing Java over C has to do with "the cleaner structure and improved reusability of the code, and the way it better models the problem domain". Explain carefully what she means by this statement (c) The questions that follow concern this statement from a Java program List data new ArrayList(); (i) The author of this code has made a typing error that will prevent it from compiling Why does the problem occur? What change is needed to fix it? (ii) The statement refers to a List on the left hand side of the assignment, rather than an ArrayList. Why is this not a problem? What, in general, is the benefit of doing this? (iii) What are the circumstances under which ArrayList is an appropriate choice of implementation for this particular list? (d) A computer science student is given the task of writing Java software to tally votes in a Student Union election. He decides to represent candidate names as a list of strings and the corresponding total votes for each candidate as a list of integers. Explain the drawbacks of this approach. Propose a better Java data structure for the task, explaining clearly why it is superior. Give an example of the code needed to create an instance of this data structure Question 2 (a) A programmer decides to use Java instead of C in a project, partly because "errors are handled better and debugging is easier". With reference to the features and the programming environments of both languages, explain why the programmer might have arrived at this conclusion (b) The programmer in (a) notes that her main reason for choosing Java over C has to do with "the cleaner structure and improved reusability of the code, and the way it better models the problem domain". Explain carefully what she means by this statement (c) The questions that follow concern this statement from a Java program List data new ArrayList(); (i) The author of this code has made a typing error that will prevent it from compiling Why does the problem occur? What change is needed to fix it? (ii) The statement refers to a List on the left hand side of the assignment, rather than an ArrayList. Why is this not a problem? What, in general, is the benefit of doing this? (iii) What are the circumstances under which ArrayList is an appropriate choice of implementation for this particular list? (d) A computer science student is given the task of writing Java software to tally votes in a Student Union election. He decides to represent candidate names as a list of strings and the corresponding total votes for each candidate as a list of integers. Explain the drawbacks of this approach. Propose a better Java data structure for the task, explaining clearly why it is superior. Give an example of the code needed to create an instance of this data structure

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions