Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

f Question 1 1.1 Discuss temporary and permanent data, highlighting the advantag

ID: 3728324 • Letter: F

Question

f

Question 1

1.1 Discuss temporary and permanent data, highlighting the advantages and disadvantages of each. (10)

1.2 Besides variables, name other ways to store information in temporary storage. (5)

1.3 Explain the concept data abstraction. (5)

State whether the following statements are True or False. Write down the question number and the word True or False next to it. E.g.1.4 True

1.4.1 A single array can hold components of many different data types.

1.4.2 The constructor is called when an object is created.

1.4.3 Given the declaration, int[] list = new int[50]; the statement, System.out.println(list); outputs all 50 components of the array list, one component per line.

1.4.4 Get and set methods are used to obtain and change the values of an objects attributes.

1.4.5 A file is a place to store data we wish to persist after our program has terminated.

1.4.6 In Java, the array index starts at 1.

1.4.7 Arrays are made up only of integers.

1.4.8 The ability of a family of related classes to each implement their own version of a method is an example of polymorphism.

Explanation / Answer

1.1 Discuss temporary and permanent data, highlighting the advantages and disadvantages of each. (10) Answer: Temporary Data have short lifetime, usually to hold data that will soon be discarded, or before it can be placed at a more permanent memory location. A typical example would be that of swapping the contents of two variables. To swap the contents of variables a and b one would typically use a temporary variable temp as follows, so as to preserve the data from a as it is being overwritten by b: temp := a a := b b := temp Advantage : Uses less memory Create memory at run time only Disadvntage : some time memory may be less Permanent Data have full lifetime untill program kill. Global variables and static variables are generaly permanent data of a program. Advantage : can access in whole program. Disadvantage: having same data for all objects. 1.2 Besides variables, name other ways to store information in temporary storage. (5) Answer : Beside variables, we can store data in arrays and objects. and other Data structures also such as stack ,linked list, tree. Arrays are continous memory location of similar data types. For example : int arr[20]; 1.3 Explain the concept data abstraction. (5) Answer : Data abstraction is the programming process of creating a data type, usually a class, that hides the details of the data representation in order to make the data type easier to work with. Data abstraction involves creating a representation for data that separates the interface from the implementation so a programmer or user only has to understand the interface, the commands to use, and not how the internal structure of the data is represented and/or implemented. State whether the following statements are True or False. Write down the question number and the word True or False next to it. E.g.1.4 True 1.4.1 A single array can hold components of many different data types. False. Array can hold similar type of data. 1.4.2 The constructor is called when an object is created. True. Constructor is called when object created. it use to initialize the object with values. 1.4.3 Given the declaration, int[] list = new int[50]; the statement, System.out.println(list); outputs all 50 components of the array list, one component per line. False. This print list object value. 1.4.4 Get and set methods are used to obtain and change the values of an objects attributes. True. Get method use for getting the data and set method sets the data 1.4.5 A file is a place to store data we wish to persist after our program has terminated. True. File can store data after program ends. 1.4.6 In Java, the array index starts at 1. False. Array index starts with 0. 1.4.7 Arrays are made up only of integers. False. Array is use to store any type of similar data types data. 1.4.8 The ability of a family of related classes to each implement their own version of a method is an example of polymorphism. True. Classes can be an example of polymorphism using inheritance.