An object is an instance of a class. Objects hold any information , but
classes don’t have any information. Definition of properties and
functions can be done at class and can be used by the object.
Home »
OOPS-Interview-Questions
» Difference between class and an object?
Difference between class and an object?
PMA02:57
Categories: OOPS-Interview-Questions
Related Posts:
how create a new instance of an object? Define the class, then use new to create an instance of the class: class user { function load_info($username) { // load profile from database } } $user = new user; $user->load_info($_REQUEST['username'… Read More
Difference between class and an object? An object is an instance of a class. Objects hold any information , but classes don’t have any information. Definition of properties and functions can be done at class and can be used by the object. … Read More
how access a method in the parent class that's been overridden in the child? Prefix parent:: to the method name: class shape { function draw( ) { // write to screen } } class circle extends shape { function draw($origin, $radius) { // validate data if ($radius > … Read More
how eliminate an object? Objects are automatically destroyed when a script terminates. To force the destruction of an object, use unset( ): $car = new car; // buy new car ... unset($car); // car wreck … Read More
parent AND self PHP oops parent AND self PHP oops self::refers to the current class and it is usually used to accessstatic members, methods, and constants. parent::refers to the parent class and it is most often used when wanting … Read More
Static Methods-PHP PHP supports declaring methods as static. Whatthis means is that your static methods are part of the class and are not bound to any specific object instance and its properties. Therefore, $this isn’t acce… Read More
friend function? Friend declaration can be placed anywhere in the class declaration. Friend function that is a "friend" of a given class is allowed access to public, private, or protected data in that class. … Read More
function overloading? Function overloading is defined as a normal function, but it has the ability to perform different tasks. It allows creation of several methods with the same name which differ from each other by type of input and output of… Read More
PHP INTERFACES Class inheritanceenables you to describe a parent-child relationshipbetween classes. For example, you might have a base class Shapefrom which both Squareand Circlederive. However, you might often want to add a… Read More
want to link two objects, so when you update one, you also update the other? Use =& to assign one object to another by reference: $adam = new user; $dave =& $adam; … Read More
how execute different code depending on the number and type of arguments passed to a method? PHP doesn't support method polymorphism as a built-in feature. However, you can emulate it using various type-checking functions. The following combine( ) function uses is_numeric(), is_string(), is_array(), and is_bool(… Read More
default access specifier in a class definition? Private access specifier is used in a class definition. … Read More