Advanced Programming – Need Programming Assignment Help

Question 1

a) Consider the following sequence of instructions in Java. In the table below, state what each and every variable contains before or after each statement is executed.

1. int j = 2;
2. int k = 5;
3. int m = 3 + 2 * 4;
4. double v = 1.0 / 2.0;
5.
6. v = k / 2.0;
7. m = k / j;
8. k = k % m;
9. v = m + j;

b) In Object-oriented programming, what is the difference between a class and an object? Provide a real world example to support your answer.

c) Explain, with the aid of an example and a diagram, the difference between an object and an object variable.

d) In addition to a body of a method, there are three other parts to a method definition. Name each of these parts.

e) What general name is given to the method that initialises an object’s data members when an object is instantiated?

f) One of the powerful features of OOP is “encapsulation”. Describe the meaning of this term and its benefits.

g) Explain how you can achieve encapsulation in the Java programming language.

 

Order Now - AllAssignmentHelp

Order Now – AllAssignmentHelp

Question 2

a) Questions (i) to (vii) relate to the following code. A class called Point is defined and the code fragments that are called from main() are given line numbers 1 to 7.
public class Point {
private int x;
private int y;
public Point(int xIn, yIn) {
x = xIn ;
y = yIn ;
}
public int getX() {
return x ;
}
}
The following code is called from main()
1. Point[] points = new Point[2];
2. Point a = new Point(1, 1);
3. Point b = new Point(2, 0);
4. Point c = new Point(0, 2);
5. points[0] = a;
6. points[1] = b;
7. int value = points[1].getX();
//after run the above code, now we add line
8. points[2] = c;

Explain, using a diagram to support each of your answers

Free Live Chat

Free Live Chat

(i) What has been created and stored after line 1 is executed?

(ii) What has happened after lines 2 – 4 are executed?

(iii) What has happened after lines 5 and 6 are executed?

(iv) What is stored in the array points before line 7 is executed?

(v) What has happened after line 7 is executed?

(vi) What is stored in value at line 7?

(vii) What happens when we recompile after line 8 is added?

 

b) Discuss any problem you consider may arise from the above program. Suggest a possible solution to this and explain how it would work.

 

Question 3

a) Describe the difference between aggregation and inheritance in object-oriented programming.

 

b) A class called Employee has attributes for the name of the person and his/her salary, together with methods for accessing the attributes and
methods for setting the attributes. A class SalesPerson is inherited from class Employee (described above), and has an attribute representing a bonus. It also has methods for accessing and setting the attribute bonus.

(i) Write a parameterised constructor for class SalesPerson which receives values for name, salary and bonus.

(ii) Provide an explanation of how the salary attribute in class Employee has been set.

(iii) Explain the difference between this and super when these words are used as the names of objects that are called in a constructor definition.

 

c) Describe, with the aid of diagrams, how you would design programs to implement the following problems. Identify the classes, attributes and the relationships between them.

(i) A bicycle has two wheels and a set of gears. Wheels are available in different sizes. The gear mechanism can have 18 or 24 gears.

(ii) A car has an engine, two or four seats and is available as a saloon or cabriolet model. A lorry has an engine, eight wheels and a capacity to carry up to a specified weight.

 

Question 4

a) Describe what the differences and fundamental operations of a stack and queue are.

b) Give two examples of non-linear data structures.

c) Describe the difference, with examples, between static and dynamic data structures.

d) Draw a visual representation of a linked-list data structure showing how object references are stored and node objects are linked to

each other.

e) Primitive data types cannot be inserted into data structures such as array lists that store only objects. Explain with one example how Java can allow the storage of primitive data types.

 

Question 5

a) Describe four features of a map data structure.

b) Describe the problems that may be encountered when computing the hash codes for adding objects into a simple array implementation of a hash table.

c) What solutions could be used to address the problems encountered in b)?

d) Describe the steps involved in finding an element in a hash table. You can use your solutions described in c) to help answer the question.

e) Name two ways in which hash tables can be designed to make the performance of the hashing algorithm more efficient.

 

Question 6

a) What properties do all nodes of a binary tree need to fulfil?

b) Draw the binary tree for the following sequence of nodes, where all nodes must fulfil the properties for binary trees:  39, 22, 18, 10, 12, 30, 54, 48, 50, 89

c) Write the code or pseudo code for searching the data stored at each node of the binary tree for some element E.

d) Describe two ways for comparing data objects while searching for data stored in a binary tree.

e) What is the big ‘O’ performance complexity for inserting a new element into a balanced binary tree?

 

Java Programming Assignment Help | Operating System Assignment Help | Data Structure Assignment Help | Need Programming Assignment Help

Advanced Programming – Need Programming Assignment Help