What is the difference between property and method?

Answers were Sorted based on User's Feedback



What is the difference between property and method?..

Answer / amarendra kothuru

Property is nothing like a variable and Method is like a
function.

You cannot pass parameters to a property and you can
directly assign value to it.

for a Method, set of lines of code and when it is called
that executes set of lines written in it and generates the
results. you can pass parameters to the method and you can
retirve the result from the method. You cannot directly
assign any value to it but you can pass it by
Parameterizing it.

Ex: Reporter.Filter - Here Filter is a property
Reporter.ReportEvent - Here ReoprtEvent is a mothod.

Reporter.Filter = 0 'this enable the results for the test
results. Here you can directly assig value to it
Reporter.ReportEvent micPass, "Msg1","Msg2". Here we are
passing three parameters to the methos ReportEvent that
send the results to Test Results.

Reporter is either a prepdefined Abstract class/interface
in QTP that has so many Properties and Moethods

Is This Answer Correct ?    31 Yes 6 No

What is the difference between property and method?..

Answer / ravi

Properties are a useful way of expressing a feature of an object, allowing get/set in a common way that can be used by APIs like data-binding, reflection and serialization. So for simple values of the object, properties are handy. Properties can't take arguments, should not have significant side-effects*, and should return quickly and repeatably. Also, there is no such thing as an "extension property" (to mirror an extension method) nor a generic property.
(*=lazy loading etc isn't uncommon, however)
Methods (C# doesn't have functions) are better for expressing things that either change the state, or which have an expectation of taking some time and not necessarily being reproducible. They don't tend to work in binding / serialization etc.
Note that properties are actually just a special way of writing methods. There is little functional difference. It is all about expressing intent. The one thing you don't want to expose, however, is fields (the actualintEmployeeAge instance variable).

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More QTP Interview Questions

WHAT IS THE FUNCTION (HOW TO DO) THE BATCH TESTING IN TEST DIRECTOR USING MANUAL TESTING PROCEDURE?

1 Answers   CTS,


A web Page has a webtable with four columns and four rows. The first column is of ID and has values of 100,100A,A100,100y Find out the number of rows whose ID starts with 100. Similarly the last column is 'number of links'. Each row in the last column has values like link1,link2,link3 etc Find out the number of links where id is 100

1 Answers   Virtusa,


What are table and db checkpoints?

0 Answers  


Among all the check points what is the most important checkpoint?

5 Answers   Semantic Space,


in how many ways you perform batchtesting?

2 Answers   Sapient,






1)what is the quality process in QTP? 2)how to add the .tsr file in qtp through scripting?

1 Answers   L&T,


How to handle Dynamically changing Objects in QTP?

4 Answers  


How can we open an Excel sheet through the script

8 Answers   eSymbiosis,


A web page title might be xxxx@xyz.com or xxxy@xxx.co or xyz@abc.in.Using what mandatory properties can be the page identified.Give the regular expression for that.

3 Answers   Virtusa,


Using Object Repository is a advantage or disadvantage?

6 Answers   Wipro,


There is a table with 4 columns and 10 rows, how to write the script to display the first column records using qtp? can anybody help me with script?

6 Answers   Oracle,


How to send the qtp results file by email (Lotus notes).

1 Answers   TCS,


Categories