Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is inheritance in php progaming?



What is inheritance in php progaming?..

Answer / dhanya

Inheritance is the extension of a class. A child class has
all the properties and methods of its parent class. For
example, pets generally share similar characteristics,
regardless of what type of animal they are. Pets eat, and
sleep, and can be given names. However the different types
of pet also have their own methods: dogs bark and cats meow.
Below is an implementation of this:

<?php
class Pet
{
var $_name;

function Pet($name)
{
$this->_name = $name;
}

function eat()
{
}

function sleep()
{
}
}

class Dog extends Pet
{
function bark()
{
}
}

class Cat extends Pet
{
function meow()
{
}
}

$dog = new Dog("Max");
$dog->eat();
$dog->bark();
$dog->sleep();

$cat = new Cat("Misty");
$cat->eat();
$cat->meow();
$cat->sleep();
?>

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More PHP Interview Questions

What is meant by variable variables in php?

0 Answers  


Tell me how to create a session? How to set a value in session? How to remove data from a session?

0 Answers  


1.Where are the cookies storing ? 2.What is the drawback of using cookies ? 3. If two site is having same cookie name and different values what will be the output if we echo the cookie name from those sites ? How can we solve this issue (How can we specify the domain name)?

8 Answers   TCS,


Which is the correct way to check if a session has already been started ?

0 Answers  


Write the statements that are used to connect php with mysql

0 Answers  


How to copy a file?

0 Answers  


Can the value of a constant change during the script's execution?

0 Answers  


How do you parse and process html/xml in php?

0 Answers  


i want to store retrieved data from database into an array list with limit.And display the data from that array list.have any answer for this?

2 Answers  


Why do we show php code in browser?

0 Answers  


Which is not a file-related function in php?

0 Answers  


How to break a file path name into parts?

0 Answers  


Categories