1. In what way is data hiding related to data abstaction?
2. Mention the steps to create an object of a class.
Answers
Answered by
2
here is ur answer.....!!!!
Data Hiding is a feature of OOP languages which doesn't let the program access an object's data directly, keeping it hidden and safe from t alteration whereas, Abstraction is a core concept of Computer Science which mainly states that - You don't need to know how the data, pages, words...etc. are being handled to execute the program. You can simply use the functions and write your code by understanding what it the construct does. Only learn and know what is needed.
To create an object:
1. Create a new PHP document in your text editor or IDE, to be named
hello_object.php , beginning with the standard HTML.
2. Include the class definition:
require('HelloWorld
In order to create an instance of a class, the PHP script must have access to that class definition . As the definition is stored in a separate file, that file must be included here.
3. Create the object:
$obj = new HelloWo
This one line of code is all there is to it! You can give the object variable any valid name you’d like, of course.
4. Invoke the sayHello() method:
$obj->sayHello();
This line of code will call the say-Hello() method, which is part of the $obj object.
5. Say hello in a few more languages:
$obj->sayHello('It $obj->sayHello('Du $obj->sayHello('Fr
An object’s methods can be called multiple times, like any other function. Different arguments are provided to vary the result.
6. Delete the object and complete the page:
unset($obj); ?> </body> </html>
You don’t technically have to delete the object—it will be deleted as soon as the script ends. Still, I think it’s better programming form to tidy up like this.
7. Save the file as
hello_object.php and place it in your Web directory, along with
HelloWorld.php .
8. Test hello_object.php by viewing it in your Web browser .
Note that you should run hello_ object.php , not HelloWorld.php , in your Web browser.
thanks....!!!!
Data Hiding is a feature of OOP languages which doesn't let the program access an object's data directly, keeping it hidden and safe from t alteration whereas, Abstraction is a core concept of Computer Science which mainly states that - You don't need to know how the data, pages, words...etc. are being handled to execute the program. You can simply use the functions and write your code by understanding what it the construct does. Only learn and know what is needed.
To create an object:
1. Create a new PHP document in your text editor or IDE, to be named
hello_object.php , beginning with the standard HTML.
2. Include the class definition:
require('HelloWorld
In order to create an instance of a class, the PHP script must have access to that class definition . As the definition is stored in a separate file, that file must be included here.
3. Create the object:
$obj = new HelloWo
This one line of code is all there is to it! You can give the object variable any valid name you’d like, of course.
4. Invoke the sayHello() method:
$obj->sayHello();
This line of code will call the say-Hello() method, which is part of the $obj object.
5. Say hello in a few more languages:
$obj->sayHello('It $obj->sayHello('Du $obj->sayHello('Fr
An object’s methods can be called multiple times, like any other function. Different arguments are provided to vary the result.
6. Delete the object and complete the page:
unset($obj); ?> </body> </html>
You don’t technically have to delete the object—it will be deleted as soon as the script ends. Still, I think it’s better programming form to tidy up like this.
7. Save the file as
hello_object.php and place it in your Web directory, along with
HelloWorld.php .
8. Test hello_object.php by viewing it in your Web browser .
Note that you should run hello_ object.php , not HelloWorld.php , in your Web browser.
thanks....!!!!
raahul072:
thnx..!.....
Answered by
0
Answer:
Hello , mujhe pahchan rhi ho ?? hm tumse baat kr chuke hai ..1 year ago.
I think you are from Odisha..
myself Saurabh Singh from Bihar but at that time I was in kota
Similar questions