Question 1 (20 marks)
(a) Explain at least TWO (2) major aspects of an object-oriented programming (OOP).
Provide suitable examples, where necessary. [10 marks]
(b) Describe TWO (2) advantages of OOP. [10 marks]
a) The two major aspects which we will discuss are Abstraction and encapsulation.
ABSTRACTION :
We define abstraction as hiding all the unnecessary details from the user. To understand it with a real time example, let's consider a TV remote, we just press the buttons to switch amongst the channels, increase or decrease the volume, turn it on or off but have we ever thought of how it works ? The dails of how the buttons work are hidden from the outside world. Similarly, we can hide all the unnecessary details of our code from th outside world, this is what is called Abstraction. We can achieve abstraction through access modifiers which are printae, public and protected. Private functions or data members cannot be accessed outside the class and hence are hidden from the outside world.
ENCAPSULATION :
Encapsulation is defined as keeping all the data members and the functions at one place together, i.e. encapsulate them. This is achieved through a class in C++, wherein we define the members and the function for that class. This provides more readability to the code and the code looks much cleaner, making it simple to understand. For example let us take a car class.
class car
{
public :
int num_gears;
int max_speed;
int model;
};
Here we have included the model, num_gears and max_speed under one class and can be used for any car object.
b) Advantages of OOP :
In real life we deal with lot of objects such as people, car, account, etc. Hence, we need our software to be analogous to real-world objects. Real world objects have data-type properties such as name, age for people, model name for car and balance for account, etc. Moreover, real-world objects can also do certain things such as people talk, cars move, account accumulates, etc. We want our code to mimic the way these objects behave and interact. Hence, Object Oriented Programming allows the program to be closer to real world and thus making it less complex.
Also it makes the software reuse feasible and possible, for example, we don't want to define a student every time we use it, hence using OOP, we just create the blueprint for the student object and use it whenever required.
Question 1 (20 marks) (a) Explain at least TWO (2) major aspects of an object-oriented programming...
Explain both object-oriented programming and structured programming. Following your explanation of these programming methods, describe the various advantages and disadvantages of each method. Lastly, provide a justification of which method you prefer and why.
Explain, compare and contrast Procedural Programming with Object Oriented Programming concepts. Provide examples.
C++ short questions. if you can provide an exmaple to understand its better The key aspects of object oriented programming (OOP) that makes it easier to develop extensible systems are dynamic binding and polymorphism. (a) Explain how these two aspects of OOP are used to make an OO design more flexible.(b) What must a designer do, when inheriting from a base class, to ensure that this flexibility is maintained?(c) Describe what features of C++ must be used to make use...
Object Oriented Programming Question 5 (a) Brieflfly explain the role of a constructor in C++? [3 marks] (b) Can you create instance of a class without a constructor defifined in source code? Brieflfly explain your answer. [3 marks] (c) Objects model state and exhibit behaviour. Explain how state and behaviour are implemented in C++. [2 marks] [Total for Question 5: 8 marks]
Question 2 During the last years, object oriented programming has become a major aspect of software development. However, new methods for developing concurrent and distributed software systems has arisen according as communication and synchronization technologies have been advanced. Explain what software process is appropriate to develop these technologies and why.
discuss at least three major contributions or advantages of Object Oriented Systems Analysis and Design to design a Business System. Use one industry of your choice to discuss your views. For example, you can initiate your discussion as: "Following are advantages I find in creating a cyber-security system to protect patient data in healthcare," or "OOSAD can be used in creating a grocery’s supply-chain management system with the following advantages." These are examples. You can pick any industry or even...
1) Using the Object-Oriented Programming Paradigm,implement the necessary code in Python creating a ‘Car’ class with a constructor that stores all the Car information (ID, MAKE, MODEL, YEAR , COLOR, MILEAGE, PRICE_TO_DEALER, SALE_PRICE, PROFIT) as attributes. 2) Implement and add the following methods to the ‘Car' class in Question 1. a) necessary getter methods b) necessary setter methods c) method to display all the information to the screen d) a method to calculate the profit
3. (a) Outline any four features of Object-Oriented Programming OOP, giving examples in each case. [16 marks] (b) Consider the following code fragments: If a = 10; Evaluate the new value of “b” in the following: (i) b = ++ a; (ii) b = a ++; What value would a and b store in (i) and (ii) after program execution? [4 marks] 4. Create a C++ program that makes use of three arrays; name, mark, grade. The program should accept...
Question 3 (20 marks) a. Explain the location advantages of FDIs. Discuss the value of acquiring location advantages. (10 marks) b. Identify TWO (2) reasons why a home country might support outgoing foreign direct investments. (10 marks)
Object oriented programming question. Answer part a and b. 8a) Exponentiation can be implemented efficiently using the following equations. 2n 2n+1 2n x Write the recursive method exp that calculates x using this algorithm. public static double exp (double x, int n) should return x raised to the power n. (5 marks) b Show the sequence of method calls that your definition generates for the invocation exp (3,6). (3 marks