Method in oop

NadimozzamanPappo 350 views 9 slides Jun 06, 2016
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

What is method in oop? like c++,Java


Slide Content

Method Md. Nadimozzaman Pappo

What is Method? A block of instructions/codes defined as - On procedural language(C) – a Procedure On OOP(C++,Java) – a procedure associated with an object class OOP - Specifically an objects behavior

How to declare a Method? Return type Method Name Arguments M ethod Body Structure: return_type method_name (argument list){ instruction 1; …………. Method Body …………. Instruction n; }

Method in Procedural Languages - C They are called - Function Return type – void, int , double etc Function naming, Arguments, Method Body Receive parameters from caller Perform the operations defined on body Return result or void to the caller

Method in OOP – C++,Java Characteristics – Access specifier , Modifier, Return-type, Method name, Parameter list, Prototyping, Method body Acts like objects behavior Also called Member Functions Receive parameters from caller Perform the operations defined on body Return result or void to the caller

Why use Methods? Reusability, Portability Creating abstraction/ conceptual unit Methods can be called recursively Code readability To simplify

Method Example in C

Method Example in C ++ & Java

Famous Methods - C,C++,Java Main function Constructor Abstract Methods Virtual Method