Angular 7 Interview Questions

A list of top frequently asked Angular 7 Interview Questions and answers are given below.

1) What is Angular 7? How is it different from AngularJS?

Angular7 is the latest and recent version of Angular. AngularJS was the first version of Angular which is also known as Angular 1.0.

Angular7 is the complete rewrite of the Angular1.0. It supports two-way data binding, and some other features like ng update, ng add, Angular Elements, Angular Material + CDK Components, Angular Material Starter Components, CLI Workspaces, Library Support, Tree Shakable Providers, Animations Performance Improvements, and RxJS v6 etc.

2) What is Angular framework?

Angular is a TypeScript-based open-source web framework and a platform. It is used to build web/ mobile and desktop applications.

Main features of this framework are: Declarative templates, dependency injection, end to end tooling etc. These features make web development easy in Angular.


3) What is the difference between AngularJS and Angular?

Angular is a complete rewrite of AngularJS. It is a component-based framework in which an application is a tree of individual components.

Difference between AngularJS and Angular:

AngularJSAngular
AngularJS is based on MVC architecture.Angular is based on Service/Controller.
It uses JavaScript to build the application.It uses TypeScript to build the application.
It follows controller concept.It follows Component based UI approach.
It is not a mobile-friendly framework.It is a mobile friendly framework.
It is very difficult to create a SEO friendly application in AngularJS.By using Angular, you can easily create a SEO friendly application.

4) What is the difference between structural directive and attribute directive in Angular 7?

Structural directives are used to alter the DOM layout by removing and adding DOM elements. These directives are far better in changing the structure of the view. Examples of Structural directives are NgFor and Nglf.

Attribute Directives are used as characteristics of elements. For example, a directive such as built-in NgStyle in the template Syntax guide is an attribute directive.


5) What is the difference among “declarations”, “providers” and “import” in NgModule?

Difference among declarations”, “providers” and “import” in NgModule:

  • declarations are used to make directives (including components and pipes) from the current module available to other directives in the current module. Selectors of directives, components or pipes are only matched against the HTML if they are declared or imported.
  • providers are used to make services and values known to DI. They are added to the root scope and they are injected to other services or directives that have them as dependency. A special case for providers is lazy loaded modules that get their own child injector. Providers of a lazy loaded module are only provided to this lazy loaded module by default (not the whole application as it is with other modules).
  • import makes the exported declarations of other modules available in the current module.

6) What are the key components of Angular?

Key components of Angular:

Components: Components are the basic building blocks of angular application and used to control HTML views.

Modules: Modules are the set of angular basic building blocks like component, directives, services etc. An application is divided into logical pieces and each piece of code is called as “module” and used to perform a single task.

Templates: Templates are used to represent the views of an Angular application.

Services: It is used to create components which can be shared across the entire application.

Metadata: This can be used to add more data to an Angular class.


7) Explain the Architecture overview of Angular.

Angular is the most popular web development framework for developing mobile and web applications. It uses cross platform mobile development called IONIC that’s why it is not limited to web apps only.

There are 7 main building blocks of an Angular application:

  • Component
  • Templates
  • Metadata
  • Data Binding
  • Directives
  • Services
  • Dependency Injection

The basic building blocks of an Angular application are NgModules, which provide a compilation context for components. Angular app is defined by a set of NgModules and it always has at least a root module that enables bootstrapping, and many more feature modules.

  • Components define Template views
  • Components use services

The NgModules make developers to organize an application into connected blocks of functionality.

The NgModule properties for the minimum “AppModule” generated by the CLI are as follows:

  • Declarations: Use to declare the application components.
  • Imports: Every application must import BrowserModule to run the app in a browser.
  • Providers: There are none to start.
  • Bootstrap: This is a root AppComponent that Angular creates and inserts into the index.html host web page.

8) How would you update Angular 6 to Angular 7?

You can update Angular 6 to Angular 7 by using the following command:

  1. ng update @angular/cli @angular/core   

9) What is the UrlSegment Interface in Angular 7?

In Angular 7, the UrlSegment interface represents a single URL segment, constructor, properties and methods like this:

  1. class UrlSegment {  
  2. constructor(path: string, parameters: {…})  
  3. path: string  
  4. parameters: {…}  
  5. toString(): string  
  6. }  

The UrlSegment is a part of a URL between the two slashes and it contains a path and matrix parameters associated with the segment.


10) What is Do Bootstrap (ng Do Bootstrap) In Angular 7?

The ng Do Bootstrap is a new life-cycle hook added in Angular 7 and Do Bootstrap is an interface.

Example

  1. //ng Do Bootstrap – Life-Cycle Hook Interface  
  2. classApp Module implements Do Bootstrap {  
  3. ng Do Bootstrap(appRef: ApplicationRef) {  
  4. appRef.bootstrap(AppComponent);  
  5.   }  
  6. }  

11) What are directives in Angular7?

In Angular7, directives are used to add behavior to an existing DOM element or an existing component instance.

For Example

  1. import { Directive, ElementRef, Input } from ‘@angular/core’;  
  2. @Directive({ selector: ‘[myHighlight]’ })  
  3. export class HighlightDirective {  
  4.     constructor(el: ElementRef) {  
  5.        el.nativeElement.style.backgroundColor = ‘green’;  
  6.     }  
  7. }  

Now this directive extends HTML element behavior with a green background as below:

Highlight me!

12) What are components in Angular7?

Components are the basic building blocks of an Angular app formed like a tree structure. Components are subset of directives but unlike directives, components always have a template and only one component can be instantiated per an element in a template.

For example:

  1. import { Component } from ‘@angular/core’;  
  2. @Component ({  
  3.    selector: ‘my-app’,  
  4.    template: ` <div>  
  5.       <h1>{{title}}</h1>  
  6.       <div>Learn Angular6 with examples</div>  
  7.    </div> `,  
  8. })  
  9. export class AppComponent {  
  10.    title: string = ‘Welcome to Angular world’;  
  11. }  

13) What is the difference between component and directive?

A component (@component) is a directive with a template. Some major difference between components and directives are:

ComponentDirective
If you register a component, you have to use @Component meta-data annotationIf you register a directive, you have to use @Directive meta-data annotation
Components are used to break up the application into smaller components.Directives are used to design re-usable components.
Components are used to create UI widgets.Directives are used to add behavior to an existing DOM element.
Only one component can be present per DOM element.Many directives can be used per DOM element.
@View decorator or templateurl/template are mandatoryDirectives don’t use View.

14) What is a template in Angular7?

A template is a HTML view where you display your data by binding controls to Angular component’s properties. You can store your component’s template in one of two places. You can define it inline using the template property, or you can define the template in a separate HTML file and link to it in the component metadata using the @Component decorator’s templateUrl property.

For example:

Using inline template with template syntax

  1. import { Component } from ‘@angular/core’;  
  2. @Component ({  
  3.    selector: ‘my-app’,  
  4.    template: ‘  
  5.       <div>  
  6.          <h1>{{title}}</h1>  
  7.          <div>Learn Angular</div>  
  8.       </div>  
  9.    ‘  
  10. })  
  11. export class AppComponent {  
  12.    title: string = ‘Hello World’;  
  13. }  

Using separate template file such as app.component.html

  1. import { Component } from ‘@angular/core’;  
  2. @Component ({  
  3.    selector: ‘my-app’,  
  4.    templateUrl: ‘app/app.component.html’  
  5. })  
  6. export class AppComponent {  
  7.    title: string = ‘Hello World’;  
  8. }  

15) What is a module?

Modules are the logical boundaries in the application. An application is divided into separate modules to separate the functionalities of the application.

For example: app.module.ts root module declared with @NgModule decorator

  1. import { NgModule }      from ‘@angular/core’;  
  2. import { BrowserModule } from ‘@angular/platform-browser’;  
  3. import { AppComponent }  from ‘./app.component’;  
  4. @NgModule ({  
  5.    imports:      [ BrowserModule ],  
  6.    declarations: [ AppComponent ],  
  7.    bootstrap:    [ AppComponent ]  
  8. })  
  9. export class AppModule { }  

Here, the NgModule decorator has three options:

  • The imports option is used to import other dependent modules. The BrowserModule is required by default for any web based angular application.
  • The declarations option is used to define components in the respective module.
  • The bootstrap option tells Angular which Component to bootstrap in the application.

16) What are the new features added in Angular7?

Following is a list of new features added in Angular7:

  • Angular7 displays an elegant look in the new update.
  • It provides virtual scrolling by using the scrolling package .
  • It facilitates you to use drag and drop property by using the @angular/cdk/drag-drop module.
  • In Angular7, libraries make changes to itself automatically with the updated version of the Material design.
  • Angular7 provides better error handling for @Output if property is not initialized.
  • Angular7 provides added support for Node v10.

Some more Angular7 features are:

Angular Console: It is a downloadable console to start and run Angular projects on your local machine.

@angular/fire: It is a latest update on npm, and has its first stable release for Angular7.

NativeScript: It facilitates you to make a single project that builds for both web and installed mobile.

StackBlitz: StackBlitz 2.0 is now released and includes the Angular Language Service and more features like tabbed editing.

PHP Interview Questions

What is PHP?

PHP is one of the most popular server-side scripting languages for developing a web application.

The full form of PHP is Hypertext Preprocessor.

There are several benefits of using PHP. First of all, it is totally free to use. So anyone can use PHP without any cost and host the site at a minimal cost.

It supports multiple databases. The most commonly used database is MySQL which is also free to use. Many PHP frameworks are used now for web development, such as Zend, CakePHP, Laravel etc. and CMS are Magento, WordPress, joomla.

What’s the latest version of php?

   Stable release‎: ‎7.3.10 / September 26, 2019

When PHP 7.0 was released, it is claimed to be twice as fast as PHP 5.6. Now, PHP 7.3 is 31% faster than PHP 7.0 

Taking a look at the improvements in php 7.0:

  • Improved performance: It is 2x faster than php 5.0.
  • Reduced memory usage.
  • Abstract syntax tree.
  • Consistent 64-bit support.
  • Improved exception hierarchy.
  • Many fatal errors converted to exceptions.
  • Return and scalar type declaration.
  • Anonymous classes.
  • Zero cost asserts.

Rasmus Lerdorf, founder of php said “theoretically, you could turn off half the servers of data centres after upgrading to php 7.0”.

What is PEAR in PHP?

PEAR is a framework and repository for reusable PHP components. PEAR stands for PHP Extension and Application Repository. It contains all types of PHP code snippets and libraries.

What are PHP Data Types.

PHP data types are used to hold different types of data or values. PHP supports 8 primitive data types that can be categorized further in 3 types.

Scalar Types: There are 4 scalar data types in PHP.

boolean

integer

float

string

Compound Types: There are 2 compound data types in PHP.

array

object

Special Types: There are 2 special data types in PHP.

resource

NULL

How many types of array are there in PHP?

There are three types of array in PHP:

  1. Indexed array: an array with a numeric key.
  2. Associative array: an array where each key has its specific value.
  3. Multidimensional array: an array containing one or more arrays within itself.

PHP include vs PHP require

If file is missing or inclusion fails, include allows the script to continue but require halts the script producing a fatal E_COMPILE_ERROR level error.

PHP cookie

PHP cookie is a small piece of information which is stored at client browser. It is used to recognize the user.

Cookie is created at server side and saved to client browser. Each time when client sends a request to the server, cookie is embedded with request. Such way, cookie can be received at the server side.

PHP setcookie() function is used to set cookie with HTTP response. Once the cookie is set, you can access it by $_COOKIE superglobal variable.

Syntax:

  1. bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path     
  2. [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] ) 

persistent cookie is permanently stored in a cookie file on the browser’s computer. By default, cookies are temporary and are erased if we close the browser.

PHP Session

PHP Engine creates a logical object to preserve data across subsequent HTTP requests, which is known as session.

Sessions generally store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same user.

PHP session technique is widely used in shopping websites where we need to store and pass cart information e.g. username, product code, product name, product price etc from one page to another.

PHP session_start() function is used to start the session. It starts a new or resumes existing session. It returns existing session if session is created already. If session is not available, it creates and returns new session.

Example

  1. session_start(); 
  2. session_register($ur_session_var); 
  3. session_destroy()

What is the difference between session and cookie?

The main difference between session and cookie is that cookies are stored on user’s computer in the text file format while sessions are stored on the server side.

You can manually set an expiry for a cookie, while session only remains active as long as browser is open.

How can you send email in PHP?

The mail() function is used to send email in PHP.

  1. bool mail($to,$subject,$message,$header);

How can we increase execution time of a PHP script?

By default, the maximum execution time for PHP scripts is set to 30 seconds

You can change the script run time by changing the max_execution_time directive in the php.ini file. When a script is called, set_time_limit function restarts the timeout counter from zero.

What are the different types of errors in PHP?

There are 3 types of errors in PHP.

  1. Parse Errors– This type of error occurs when the coder uses a wrong syntax in the script.
  2. Notices:These are non-critical errors. These errors are not displayed to the users.
  3. Warnings:These are more serious errors, but they do not result in script termination. By default, these errors are displayed to the user.
  4. Fatal Errors:These are the most critical errors. These errors may cause due to immediate termination of script.

What is htaccess in PHP?

The .htaccess is a configuration file on Apache server. You can change configuration settings using directives in Apache configuration files like .htaccess and httpd.conf.

What is the use of Apache?

Apache httpd 2.4.41 Released 2019-08-14

Apache is an open-source and free web server software that powers around 46% of websites around the world. The official name is Apache HTTP Server, and it’s maintained and developed by the Apache Software Foundation.

What is nginx?

 the latest version of Nginx is 1.17.0, released on May 21, 2019.

NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. NGINX is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.

NGINX is about 2.5 times faster than Apache based on the results of a benchmark test running up to 1,000 concurrent connections. … Clearly, NGINX serves static content much faster than Apache. If you need to serve a lot of static content at high concurrency levels, NGINX can be a real help

Apache Vs NGINX 2019

The main difference between Apache and NGINX lies in their design architecture. Apache uses a process-driven approach and creates a new thread for each request. Whereas NGINX uses an event-driven architecture to handle multiple requests within one thread.

Software Development Life Cycle Models and Methodologies

The Software Development Lifecycle (SDLC) is a systematic process for building software that ensures the quality and correctness of the software built. SDLC process aims to produce high-quality software which meets customer expectations.

SDLC Phases

  • Phase 1: Requirement and Analysis
  • Phase 2: Feasibility study
  • Phase 3: Design
  • Phase 4: Coding
  • Phase 5: Testing
  • Phase 6: Deployment
  • Phase 7: Maintenance

Waterfall Model

Waterfall Model

The Waterfall – is a cascade SDLC model

The Waterfall Model was the first Process Model to be introduced. It is very simple to understand and use. In a waterfall model, each phase must be completed before the next phase can begin and there is no overlapping in the phases.

Advantage:

Easy to understand

Easy to explain to the users.

Disadvantages:

Very difficult to go back to any stage after it finished.

Costly and required more time.

V-Shaped Model

It is an extension of the waterfall model, Instead of moving down in a linear way, the process steps are bent upwards after the implementation and coding phase means associated test stage after every development stage, to form the typical V shape. The major difference between the V-shaped model and waterfall model is the early test planning in the V-shaped model.

This is also called “Validation and verification” model.

V-Shaped

Advantage:

Simple and easy to use

Disadvantages:

Costly and required more time.

Iterative and Incremental Model

It is developed to overcome the weaknesses of the waterfall model. It starts with an initial planning and ends with deployment with the cyclic interactions in between. The basic idea behind this method is to develop a system through repeated cycles (iterative) and in smaller portions at a time (incremental), allowing software developers to take advantage of what was learned during the development of earlier parts or versions of the system. It can consist of mini waterfalls or mini V-Shaped model

The Iterative SDLC model does not need the full list of requirements before the project starts.

incremental-sdlc

Advantages:

Produces business value early in the development lifecycle.

We can detect project issues and changes earlier.

Disadvantages:

  • Requires heavy documentation.
  • Follows a defined set of processes.

Prototyping Model

It refers to the activity of creating prototypes of software applications, for example, incomplete versions of the software program being developed.

  • Throwaway prototyping
  • Evolutionary prototyping
  • Incremental prototyping
  • Extreme prototyping

Advantages:

  • Reduced time and costs, but this can be a disadvantage if the developer loses time in developing the prototypes.
  • Improved and increased user involvement.

Disadvantages:

  • Insufficient analysis. User confusion of prototype and finished system.s
  • Excessive development time of the prototype.
  • It is costly to implement the prototypes

Spiral Model

Spiral model combines architecture and prototyping by stages. It is a combination of the Iterative and Waterfall SDLC models with the significant accent on the risk analysis.

spiral model

The spiral model is favored for large, expensive, and complicated projects.Advantages:

  • Estimates (i.e. budget, schedule, etc.) become more realistic as work progresses, because important issues are discovered earlier.
  • Early involvement of developers.
  • Manages risks and develops the system into phases.

Disadvantages:

  • High cost and time to reach the final product.
  • Highly customized limiting re-usability

Agile Model

In the agile methodology after every development iteration, the customer is able to see the result and understand if he is satisfied with it or he is not. This is one of the advantages of agile software development life cycle model. One of its disadvantages is that with the absence of defined requirements it is difficult to estimate the resources and development cost.

agile-SDLC

It can be used with any type of the project, but it needs more engagement from the customer and to be interactive. This will enable more valuable and workable piece for software early which also increase the customer satisfaction.

Advantages:

  • Saves a great amount of cost and time for less documentation requirements
  • Face to face communication and continuous inputs from customer representative leaves no space for guesswork.
  • The end result is the high-quality software in the least possible time duration and satisfied customer.
  • Capable of accommodating new changes or enhancements occurring during the development phase without the budget constraint

Disadvantages:

  • Almost impossible to determine the effort estimation at the very beginning of the software development for full-size and complex projects
  • High-risk probability when clients/end-users are unsure about requirements
  • Necessitates experienced resources

A Scrum is a form of implementation of the Agile methodology that helps development teams to structure complex project requirements. To complete assigned tasks, Scrum teams work in sprints, which is a period that could last anywhere between 2 to 4 weeks.

Daily Scrum meetings are organized to help the complete team monitor progress made throughout the project up until that point.

The one in charge of the Scrum team is known as the ScrumMaster.

PHP OOPS Interview Questions

OOPS (Object Oriented Programming) 

OOP is a design concept. In object oriented programming, everything will be around the objects and class. By using OOP in php you can create modular web application. By using OOP in php we can perform any activity in the object model structure. There are many benefits of using oop over the parallel or procedural programming

Objects

Any thing is the world is an object. Look around and you can find lots of objects. Your laptop, pc, car everything’s an object. In this world every object has two thing properties and behaviors. Your car has property (color, brand name) and behavior(it can go forward and backward). If you are able to find properties and behaviors of real object. Then it will be very easy for you to work with Object Oriented Programming.

Class

The house blueprint is a class

Class is something which defines your object. For example your class is Car. And your Honda car is object of car class. 

Blueprint of the object is class. Class represents all properties and behaviors of an object. 

Class consists of properties and methods. Here we can take Human Being as a class.

<?php

Class House {

    public $postCode = “560121”;

    public function ringBell() {

    echo “Ding Dang Dong”;

    }

}

?>

Advantage of OOPS

  • Re-Usability of your code
  • Easy to Maintain
  • Good Level of Abstraction:
  • Molecularity

Abstraction

Abstraction is the concept of hiding the internal details and describing things in simple terms.

For example, a method that adds two integers. The internal processing of the method is hidden from the outer world.

There are many ways to achieve abstraction in object-oriented programming,

such as encapsulation and inheritance.

Encapsulation

Encapsulation is the technique used to implement abstraction in object-oriented programming.

Encapsulation is used for access restriction to class members and methods.

Access modifier keywords are used for encapsulation in object oriented programming.

For example, encapsulation in java is achieved using private, protected and public keywords.

Inheritance

Inheritance is the object-oriented programming concept where an object is based on another object.

Inheritance is the mechanism of code reuse.

The object that is getting inherited is called superclass and the object that inherits the superclass is called subclass.

The child class will inherit all the public and protected properties and methods from the parent class. In addition, it can have its own properties and methods.

 <?php

class Fruit {

  public $name;

  public $color;

  public function __construct($name, $color) {

$this->name = $name;

$this->color = $color;

  }

  public function intro() {

echo “The fruit is {$this->name} and the color is {$this->color}.”;

  }

}

// Strawberry is inherited from Fruit

class Strawberry extends Fruit {

  public function message() {

echo “Am I a fruit or a berry? “;

  }

}

$strawberry = new Strawberry(“Strawberry”, “red”);

$strawberry->message();

$strawberry->intro();

?>

Polymorphism

Polymorphism is the concept where an object behaves differently in different situations.

There are two types of polymorphism – compile time polymorphism and runtime polymorphism.

Compile-time polymorphism is achieved by method overloading. For example, we can have a class as below.

<?php

public class Circle {

public void draw(){

System.out.println(“Drwaing circle with default color Black and diameter 1 cm.”);

}

public void draw(int diameter){

System.out.println(“Drwaing circle with default color Black and diameter”+diameter+” cm.”);

}

public void draw(int diameter, String color){

System.out.println(“Drwaing circle with color”+color+” and diameter”+diameter+” cm.”);

}

}

?>

Association

Association is the OOPS concept to define the relationship between objects.

The association defines the multiplicity between objects.

For example Teacher and Student objects. There is a one-to-many relationship between a teacher and students.

Similarly, a student can have a one-to-many relationship with teacher objects.

However, both student and teacher objects are independent of each other.

Interfaces

Interfaces are defined to provide a common function names to the implementers. Different implementers can implement those interfaces according to their requirements. You can say, interfaces are skeletons which are implemented by developers.

As of PHP5, it is possible to define an interface, like this −

interface Mail {

   public function sendMail();

}

Abstract Classes

An abstract class is one that cannot be instantiated, only inherited. You declare an abstract class with the keyword abstract, like this −

When inheriting from an abstract class, all methods marked abstract in the parent’s class declaration must be defined by the child; additionally, these methods must be defined with the same visibility.

abstract class MyAbstractClass {

   abstract function myAbstractFunction() {

   }

}

Static Keyword

Declaring class members or methods as static makes them accessible without needing an instantiation of the class.

Final Keyword

PHP 5 introduces the final keyword, which prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended.

Overloading and Overriding in PHP

According to Object Oriented Programming (OOP) concept if a class has methods of the same name but different parameters then we say that we are overloading that method. Also if we were to create a method in the child class having the same name, same number of parameters and the same access specifier as in its parent then we can say that we are doing method overriding.

As we know that PHP is not type strict, means if we implement overloading in C++ or Java, the function will look like add(int,float) is different from add(float,int) or even add(float,int,int) but it is not possible in PHP. Actually polymorphism is not easy in PHP

Visibility

Each method and property has its visibility. There are three types of visibility in PHP.

They are declared by keywords public, protected and private.

Each one of them controls how a method/property can be accessed by outsiders.

Public: It allows anyone from outside access its method/property.

This is the default visibility in PHP class when no keywords are prefixed to a method/property.

Protected: It only allows itself or children classes to access its method/property.

Private: It does not allow anyone except itself to access its method/property.

Constructor Functions

Constructor Functions are a special type of functions which are called automatically whenever an object is created. So we take full advantage of this behaviour, by initializing many things through constructor functions.

PHP provides a special function called __construct() to define a constructor. You can pass as many as arguments you like into the constructor function.

Access Modifiers

Properties and methods can have access modifiers which control where they can be accessed.

There are three access modifiers:

public – the property or method can be accessed from everywhere. This is default

protected – the property or method can be accessed within the class and by classes derived from that class

private – the property or method can ONLY be accessed within the class

//Abstract classes    

An abstract class is a class that contains at least one abstract method.

An abstract method is a method that is declared, but not implemented in the code.

An abstract class or method is defined with the abstract keyword:

 <?php

abstract class ParentClass {

  abstract public function someMethod1();

  abstract public function someMethod2($name, $color);

  abstract public function someMethod3() : string;

}

?>

What are Traits?

PHP only supports single inheritance: a child class can inherit only from one single parent.

Traits are used to declare methods that can be used in multiple classes.

Traits can have methods and abstract methods that can be used in multiple classes, and the methods can have any access modifier (public, private, or protected).

Traits are declared with the trait keyword:

 <?php

trait message1 {

public function msg1() {

echo “OOP is fun! “;

  }

}

class Welcome {

  use message1;

}

$obj = new Welcome();

$obj->msg1();

?>

//Static Methods

Static methods can be called directly – without creating an instance of a class.

Static methods are declared with the static keyword:

<?php

class ClassName {

  public static function staticMethod() {

echo “Hello World!”;

  }

}

?>

Does PHP support multiple inheritances?

PHP does not support multiple inheritances. To implement the features of multiple inheritances, the interface is used in PHP.

Here, two interfaces, Isbn and Type are declared and implemented in a class, book details to add the feature of multiple inheritance in PHP.

interface Isbn { 

public function setISBN($isbn);

}

interface Type{

public function setType($type); 

}

class bookDetails implements Isbn, Type {

private $isbn; 

private $type; 

public function setISBN($isbn)

$this -> isbn = $isbn; 

}

public function setType($type)

$this -> type = $type; 

}

}

MySQL Interview Questions

MySQL Interview Questions

MySQL is a multi-threaded or multi-user database management system.

MySQL is an Oracle-supported Relational Database Management System (RDBMS) which is based on structured query language.

It is supported by most of the popular operating systems, such as Windows, Linux, etc.

The default port number of MySQL is 3306

MySQL supports wide ranges of operating systems most famous of those include Windows, Linux & UNIX

Developer(s) : Oracle Corporation

Initial release : 23 May 1995

Latest Stable release: 8.0.17 / 22 July 2019

Repository : github.com/mysql/mysql-server

Why MySQL is used?

The MySQL database server is very fast, reliable, open source and easy to use. You can easily use and modify the software. MySQL software can be downloaded free of cost from the internet.

What is the purpose of using a HEAP table?

HEAP tables are present in memory and they are used for high speed storage on temporary basis. 

The table which uses a hashed index and stores in the memory is called the HEAP table. It works as a temporary table and it uses the indexes that make it faster than another table type.

What are the different tables present in MySQL?

There are many tables that remain present by default. But, INNODB is the default database engine used in MySQL. MySQL prior to version 5.5 was MyISAM

There are five types of tables that are present:

  • INNODB
  • MyISAM
  • Heap
  • Merge
  • ISAM
  • Memory
  • CSV
  • Merge
  • Archive

What is a storage engine? What are the differences between InnoDB and MyISAM engines?

One of the major components of the MySQL server is the storage engine for doing different types of database operations. Each database table created is based on the specific storage engine.

MySQL supports two types of storage engines i.e transactional and non-transactional

InnoDB is the default storage engine of MySQL which is transactional. MyISAM storage engine is a non-transactional storage engine.

The differences between InnoDB and MyISAM storage engines are discussed below:

  • MyISAM supports the FULLTEXT index but InnoDB doesn’t support the FULLTEXT index.
  • MyISAM is faster and InnoDB is slower.
  • InnoDB supports ACID (Atomicity, Consistency, Isolation, and Durability) property but MyISAM doesn’t.
  • InnoDB supports row-level locking and MyISAM supports table-level locking.
  • InnoDB is suitable for large database and MyISAM is suitable for a small database.

What is Database White Box Testing?

The Database Whitebox Testing deals with the tables, data model, schema and referential integrity rules. It also deals with the triggers, logical views with database consistency and ACID properties.

What is Database Black Box Testing?

Database Black Box Testing deals with data mapping, data storing and retrieving. The Database Black Box Testing is used for techniques such as Equivalence Partitioning and Boundary Value Analysis.

What is a Cursor

The cursor is used for performing traversing actions such as addition, retrieval, and removal of records in a database.

What is Normalization and list the different types of normalization?

Normalization is the process of organizing data to avoid duplication and redundancy. There are many successive levels of normalization. These are called normal forms. Each consecutive normal form depends on the previous one. The first three normal forms are usually adequate.

  • First Normal Form (1NF) – No repeating groups within rows
  • Second Normal Form (2NF) – Every non-key (supporting) column value is dependent on the whole primary key.
  • Third Normal Form (3NF) – Dependent solely on the primary key and no other non-key (supporting) column value.

Table Indexes:

SHOW INDEX FROM tableName

Mysql Version: SELECT VERSION()

ACID :  Atomicity, Consistency, Isolation, and Durability that can be defined as properties of a transaction.

LAST_INSERT_ID