InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 451. |
What are the difference between abstract class and interface in OOPS? |
|
Answer» Thera are many differences between abstract CLASS and INTERFACE in php. 1. Abstract METHODS can declare with public, PRIVATE and protected. But in CASE of Interface methods declared with public. 2. Abstract classes can have constants, members, method stubs and defined methods, but interfaces can only have constants and methods stubs. 3. Abstract classes doest not support multiple inheritance but interface support this. 4. Abstract classes can contain constructors but interface doest not support constructors. |
|
| 453. |
What are the difference between overloading and overriding in oops? |
|
Answer» Overloading : It OCCURS when two or more METHODS in one class have the same METHOD name but different parameters. Overriding : It means having two methods with the same method name and parameters. One of the methods is in the PARENT class and the other is in the child class. |
|
| 454. |
What is static keyword ? |
|
Answer» When a variable or function declared as STATIC then it cannot be accessed with an instantiated CLASS object. It is treats as PUBLIC if no visibility is defined. It can ALSO be used to define static variables and for late static bindings. |
|
| 455. |
What are the Final class and Final methods? |
|
Answer» Final CLASS- A class that can’t be extended and inherited further is known as Final Class. This class is declared with the keyword final and should be declared. Final Method- METHODS in the final class are implicitly final and if a user uses the final keyword that means methods can’t be overridden by subclasses. Exampleclass childClassname extends parentClassname { public function __construct($AUTHOR, $pages) { final public function PageCount() { |
|
| 456. |
What is different types of Visibility? |
|
Answer» PHP have three access MODIFIERS such as public, private and protected.
|
|
| 457. |
What is constructor and destructor? |
|
Answer» Constructor and Destructor both are SPECIAL functions which are automatically called when an object is created and destroyed. ExampleConstructor class Animal { public $name = "No-name animal"; public function __construct() { } } Destructor class Animal { public $name = "No-name animal"; public function __construct($name) { echo "I'm alive!"; $this->name = $name; } public function __destruct() { echo "I'm dead now :("; } } $animal = NEW Animal("Bob"); echo "Name of the animal: " . $animal->name;
|
|
| 458. |
What is Polymorphism and its types in OOPS? |
|
Answer» Polymorphism is one of the core concepts which is used in object-oriented programming. Polymorphism generally shows the relationships between parent class objects and child class objects. Types of polymorphism in OOPs
It is a technique in which one class acquires the property of ANOTHER class. With the help of inheritance, we can reuse the fields and methods of the existing class. Inheritance has three type, are given below.
But PHP supports only single inheritance, where only one class can be derived from single parent class. We can also use multiple inheritance by using interfaces. |
|
| 459. |
What is Encapsulation in oops with an example? |
|
Answer» The process of binding up data and FUNCTIONS together that manipulates them is known as encapsulation in OOPS. It PROTECTS the data from outside interference and misuse. Let’s understand the concept of encapsulation with both real-world examples and with the help of a program. It is an attribute of an object, and it contains all data which is hidden. That hidden data is restricted to the members of that class.Exampleclass Account { PUBLIC void show Data() { public void deposit(int a) { |
|
| 460. |
List out some of the differences between a class and an object? |
||||||||||||||
Answer»
|
|||||||||||||||
| 461. |
What is virtual and pure virtual function? |
||||||||
Answer»
|
|||||||||
| 462. |
What is the difference between Method overriding and Method overloading? |
||||||||
Answer»
|
|||||||||
| 463. |
What are the types of Class Variables? |
|
Answer» We have THREE DIFFERENT types of Class VARIABLES in OOPs. 1. LOCAL VariablesThese types of variables are declared locally in methods, BLOCKS, and constructors. These variables are created when program control enters the methods, blocks, and constructor and are destroyed once program control leaves them. 2. Instance VariablesThese variables are declared outside a block, constructor, or method. These are created once a class object is created and destroyed when the object is destroyed. 3. Static VariablesStatic variables are also called class variables and are defined using the static keyword. These are declared within a class but outside a code block and a method. The creation of these variables starts when the program starts and is destroyed when the program ends. |
|
| 464. |
What is Class and Objects in OOPS? |
|
Answer» Class In Object-Oriented PROGRAMMING, a class is a blueprint that defines the functions and variables which are common to objects of a certain kind. ObjectIn OOPS an object is a specimen of the class. It is nothing but a component that CONSISTS of methods and properties which MAKE the data useful and help users to determine the behavior of the class. Let’s UNDERSTAND this with an exampleExampleclass Person{ public $NAME; function __construct($name){ $this->name = $name; } function getUserDetails(){ return "My name is ".$this->name; } } |
|
| 465. |
Why is object-oriented programming so popular? |
|
Answer» There are certain POINTS due to which OOPs become so popular.
|
|
| 466. |
Explain the difference between beforeRender() and beforeFilter() in cakePHP? |
|
Answer» beforeFilter() is executed before EVERY ACTION in the CONTROLLER call but beforeRender() is executed before the VIEW is rendered. |
|
| 467. |
What is Validation Model in CakePHP? |
|
Answer» CakePHP provide a very simple but powerful validation model so that we can easily manage our data validation. To do validation in CakePHP we can just need to declare a $VALIDATE array in your model class for REQUIRED fields. Example
|
|
| 468. |
What do you mean by Hooks in CakePHP ? |
|
Answer» These are the functions that we can call before and after doing any task in MODELS like after finding DATA, before SAVING data etc. |
|
| 469. |
Explain the callback functions in CakePHP? |
|
Answer» Callback FUNCTIONS just before or after a CAKEPHP model OPERATION. These callback functions can be defined in model classes.These are very SIMPLE functions which CALLED automatically when are defined by the core CakePHP.
|
|
| 470. |
What is the term "Security.salt" and "Security.cipherSeed" in CakePHP? |
|
Answer» Security.salt : It is used for GENERATING hashes. We can CHANGE it's default VALUE in /app/Config/core.php. |
|
| 471. |
List some database related query function used in cakePHP. |
| Answer» | |
| 472. |
In cakePHP, which function is first executed before every action in the controller? |
|
Answer» beforeFilter() |
|
| 473. |
How we can call a model from view in cakePHP? |
| Answer» | |
| 474. |
What do you mean by Scaffolding used in CakePHP? |
|
Answer» It is a technique that allows a user to define and CREATE a BASIC application that can create, RETRIEVE, update and delete objects in CAKEPHP. |
|
| 475. |
What do you mean by HABTM? |
|
Answer» It STANDS for "Has And BELONGS To Many" and it is a KIND of associations that can be defined in models for retrieving associated data ACROSS different entities in CAKEPHP. |
|
| 476. |
Please write the name of Cakephp database configuration file name and its location? |
|
Answer» It's DEFAULT file name is DATABASE.php.default. We can USE this file to CONFIGURE with database. This file is located in "/app/config/database.php.defaut". |
|
| 477. |
Explain the difference between Component, Helper, Behavior in cakePHP? |
|
Answer» COMPONENT : It is a Controller EXTENSION in cakePHP. |
|
| 478. |
List some key features in cakaPHP 3 over cakePHP2? |
Answer»
|
|
| 479. |
How we can set custom page title in cakePHP? |
|
Answer» To SET a custom PAGE title, COPY & paste following code anywhere in your (.CTP) file. |
|
| 480. |
How many types of caches does CakePHP support? Explain |
Answer»
|
|
| 481. |
What is the default extension of view files? How we can change it? |
|
Answer» Default extension of view file is ".CTP". We can change default extension to write public $EXT = '.yourextension' in AppController. If you WANT to change it for particular controller then please add it into that particular controller only. You can ALSO change it for the specific action of the controller by putting it in that action only. |
|
| 483. |
How we can get current URL in CakePHP? |
| Answer» | |
| 484. |
How to pass multiple parameters to access into the view files? |
|
Answer» We can use $this->set(compact()) to PASS multiple PARAMETERS to ACCESS into the view file.Example $this->set(compact('variable1','variable2','variable3')); |
|
| 485. |
How we can set layout in the controller file using cakePHP? |
|
Answer» $this->LAYOUT ="layout_name"; You can USE this in your CONTROLLER's ACTION. |
|
| 486. |
What do you mean by Component in cakephp? List some commonly used components. |
|
Answer» It is a class file that contains the common code and logic. It can be shared between the application's controllers. We can PERFORM various common tasks LIKE session handling, COOKIES and security related things with the HELP of COMPONENTS. In CakePHP, we can use various components that are given below:-
|
|
| 487. |
What is a Helper and list some common helpers name used in cakePHP? |
|
Answer» It is the component like classes for the presentation layer of our APPLICATION. Helpers CONTAIN presentational logic that is shared between any views, elements, or layouts in cakePHP. Most COMMON helpers used in cakePHP, is GIVEN below:-
|
|
| 488. |
How to use pagination in cakePHP? |
|
Answer» 1. Open your controller FILE & put below code. echo $this->Paginator->numbers(array('separator' => '','tag' => 'li', 'currentTag' => 'a', 'currentClass' => 'active'));
|
|
| 489. |
How to use session in cakePHP? |
|
Answer» It allows us to manage unique users across requests and also helps to stores data for specific users. We can access session from controllers, views, HELPERS, cells, and components. We can use session in CAKEPHP in following WAYS :-
How to create session? We can use the write() to create or write session.
How to READ session? We can use the read() to GET stored data from session.
How to Check session? We can use the check() to check this data is exists or not in session. if ($session->check('username')) {
How to delete session? We can use the delete() to delete data from session.
How to destroy session? We can use the destroy() to destroy session. |
|
| 490. |
Why we used $this->set() in cakePHP? |
|
Answer» It is used for creating a VARIABLE in the view file with $this->set('variable1','bestinterviewquestion.com'); in CONTROLLER FIE and then that variable $variable1 will be available to use in the view template file for that action. |
|
| 491. |
What are the Server Requirements for installing cakePHP? |
|
Answer» CakePHP is QUITE simple and EASY to install.
For more details you can visit cakePHP official WEBSITE Click here |
|
| 492. |
How to install cakePHP with composer? |
|
Answer» Composer is a tool USED for project dependencies. To INSTALL CAKEPHP we can use |
|
| 493. |
Write the latest version of cakePHP? |
|
Answer» CAKEPHP 3.7.2 |
|
| 494. |
Explain CakePHP and why it is used? |
|
Answer» CakePHP is a modern, open-source PHP 7 framework that makes building WEB applications simpler and FASTER. It is BASED on MVC architecture that is powerful and quick to grasp. It is used to develop web applications. 2. What are the key features of cakePHP?Explain
|
|
| 495. |
How to enable the pretty URL format in Yii2? |
|
Answer» Create an .htaccess file and add this code. RewriteEngine on # If a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Otherwise FORWARD it to index.php RewriteRule . index.php 2. Now Modify common/config/main-local.php 'urlManager' => [ 'class' => 'yii\web\UrlManager', 'showScriptName' => false, 'enablePrettyUrl' => true, 'rules' => array( '<controller:\W+>/<id:\d+>' => '<controller>/VIEW', '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>', '<controller:\w+>/<action:\w+>' => '<controller>/<action>', ), ], |
|
| 496. |
How to use asset Bundles in Yii? |
|
Answer» namespace appassets; use yiiwebAssetBundle; CLASS DemoAsset extends AssetBundle { public $basePath = ‘@webroot’; public $baseUrl = ‘@WEB’; public $JS = [‘js/demo.js’]; } |
|
| 497. |
What is widgets in Yii? How we can use it? |
|
Answer» Widgets are INSTANCES of CWidget or their CHILD class. This component is primarily for PRESENTATIONAL purposes and is embedded in the view script to HELP generate a complex UI. |
|
| 498. |
How to use session in Yii? |
|
Answer» Create Session Yii::APP()->session['name'] = "umesh singh"; Get VALUE from session $name = Yii::app()->session['name']; UNSET session like unset(Yii::app()->session['name']); Remove all session Yii::app()->session->CLEAR(); Remove session from server Yii::app()->session->DESTROY(); |
|
| 499. |
How to use form validations in Yii? |
| Answer» | |
| 500. |
List some database related query functions in Yii? |
|
Answer» 22. How we can SET DEFAULT controller in YII? You can set the default controller file through (protected/config/main.php). |
|