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

question on java 12. A method signature represents the first line of code you wr

ID: 3742538 • Letter: Q

Question

question on java

12.   A method signature represents the first line of code you write for a method in Java. It includes the following:

An access specifier which is a key word such as public followed by other optional qualifiers such as static or final.
The data type of the object or value to be returned or void if none.
The name of the method.
The data type and name of each parameter that is passed to the method.
An optional throws statement followed by the types of exceptions that the method may throw.

The method signature does not include any code from the body of method. Examples of method signatures can be found on page 16 of the text.

The nodes in a data set are objects of type: Listing.

a.   Give the method signatures for each of the four basic operations if they are performed in the node number mode.

i.           

ii.           

iii.          

iv.          

b.   Give the method signatures for each of the four basic operations if they are performed in the key field mode. Assume the key field is a String.

i.            

ii.           

iii.          

iv.          

13.   Define the terms procedural abstraction and data abstraction.

a.   Procedural abstraction

b.   Data abstraction.

14.   Define the term encapsulation.

15.   What is the Java keyword that encapsulates data inside an object?

Explanation / Answer

13a. Procedural abstraction is a model of what we want a subprogram to do(but not how to do it). When we start actually writing the code, we implement a procedural abstraction by:

1. Assigning an appropriately named function to represent the procedural abstraction

2. In the main code, calling that function, trusting that it will actually do what we want but not worrying about how to do it.

3. Writing a function body using an appropriate alogrithm to do what we want

b. Data abstraction- Data abstraction pretty much works the same way. It is a model of what can be done to a collection of data. It also excludes details of how to do it

We can do this by:

1. choosing a data structure that actually fits what we want.

2. providing appropirate operations to manipulate the data.

14. Encapsulation- It is the process of hiding the internal workings of a class from the outside world. This can be done because we dont want anyone to see what we are working with. This makes our program a little more secure because it is easier to attack a program where we know the names of variables and functions and everything else. Both data and functions can be encapsulated. The general trend is encapsulating all the data structures and leaving all the functions open for the world so the outside world can only do what you want them to do.

15. private is the keyword that encapsulates both data and methods in java.