An object in a program is a representation of any real-world thing. This can be a person, address, report, or a tree for that matter.
A class is like a blueprint of that object. It defines the structure of it.
Method Overloading is the idea that one name for a method or set of instructions in a program can be used by multiple classes and it will react differently based on the class of the object. For example lets we have a car class, a person class and a bicycle class. The idea of overloading the method allows us to create a method called move that will include the instructions for how each should move. This allows us to not have to worry so much about the type of object when telling it what to do.
Method Overriding is the concept of having one class function as an extention of another class. For example if we had a person class we could create a child class from it. Most of the functions would be the same, but for example a drive method in the person class would drive a car while the child class the same method would be overridden to drive a bicycle.
Polymorphism states that the same name for a method can be used in multiple classes and the same message can be sent to multiple classes and the correct response will be produced. This is made possible with method overloading and overriding.
A process is for independent tasks. Usually a program has one or more processes that run for the entire time that the program is executing.
A thread on the other hand is inside of a process and usually runs inside of a specific method. This allows for faster execution of programs because with multiple threads running there can be multiple actions occuring at the same time during the program. The difference is that the threads will start and stop while the application is running.
2007-01-01 01:19:35
·
answer #1
·
answered by N_lien 3
·
1⤊
0⤋
Class is a definition of an object. It defines an object and is used in creating an object. Example: A class that defines an employee contains the employees name and wage, and some functions to change the wage.
Object is an instance that represents something defined by the class that the object is made from. Example: An object that represents an employee.
Method Overloading is using the same names for two or more related functions. For example, you have a class that represents a cartesian coordinate system. You want the class to be able to calculate the distance between two coordinates. You want the class to accepts two coordinate to calculate the distance, but you also want the class to be able to accept six integer value representing the x1, y1, z1, x2, y2, z2 of the two coordinate. Rather than using different two function name for the two definition which essentially do the same thing, you would overload the Distance method with two function, and the compiler would be able to choose correctly which functions to call depending on the input.
Method overriding is replacing a function or property in the parent class with a new function of property definition in the child class (I assume you've already understand about object inheritance). For example, you inherits a manager class from an employee class. The employee have a function that raise it's wage by 10%, the function is named RaiseWage. Since manager class is inherited from employee class, this mean that the manager would also have a function that raise it's wage by 10%. OK, you think it's too much and manager should only have it's wage raised by 5%. You would then define a function that raise wage by 5% with the name RaiseWage. The compiler would then choose the 5% Manager class' RaiseWage methods if the RaiseWage parameter is a manager class, and choose 10% employee class' RaiseWage methods if the RaiseWage parameter is other employee types.
Polymorphism is better described in example:
You have an employee class.
You have a director class, manager class, and janitor class all inherited from the employee class.
Employee class have 10% RaiseWage method.
Director class have 3% RaiseWage Method.
Manager class have 5% RaiseWage Method.
Janitor class' RaiseWage method is not overriden.
You call a function like this:
Pseudo:
For All Employee
RaiseWage(em)
EndFor
em could be a director, manager, or janitor class the runtime would correctly choose director's 3%RaiseWage method if em is director, manager's 5%RaiseWage Method if em is Manager or Employee Class 10%RaiseWage method if em is Janitor or plain employee. You wouldn't need to check for the em class type yourself.
Thread is a single path of execution that can run independently from other threads, while process is a collection of threads that share the same memory space. A process contains at least one thread.
2007-01-01 20:35:11
·
answer #2
·
answered by Lie Ryan 6
·
1⤊
0⤋
Jobless,
OOP means that you are programming in an object oriented manner. Basic , C Pascal even at some level VB6 were
mostly procedural languages. Now since C++ , Java , C#
Ruby came over you will be using an object oriented manner to program. The difference is that with OOP everythings is "OBJECT" A class name "DOG" has different sub object & methods that can inlude the clor of the dog , the size of the dog etc.. so as you can see every "OBJECT" communicate with each other which makes programming easy. Even classes between each other can communicate. The advantage? One you need to modify something into the code you only modify the mother Class and the rest follow. In the procedural way you had to modify the all code to change something minor. That's the biggest different. Now OOP is not that easy to pick up but as soon you up & going you will find OOP much better & easier than Procedural programming.
Joe.
2007-01-01 05:52:32
·
answer #3
·
answered by Roland 1
·
1⤊
0⤋
an object is something you are working with in your program such as a variable
a class is the definition or blueprint for how the computer creates that object
a method is a function that is tied to the object - ie it is something that the object "can do"
overloading is having a class of object which has several different methods which have the same name - the computer knows which method to use by the number of parameters supplied when the method is called
polymorphism is basically overriding as applied to inherited methods
a thread is a "path of execution" top the processor - one process can use many threads or paths simultaneously
2007-01-01 00:53:36
·
answer #4
·
answered by Ivanhoe Fats 6
·
1⤊
0⤋
you say this when a mistake happens
2007-01-01 00:50:20
·
answer #5
·
answered by Anonymous
·
0⤊
2⤋