Blog Details

Home Blogs

blog-img01

Interview Questions

Interview Questions

OOP(Object Oriented Programming)
SL NoDescription
Features of OOP(Object Oriented Programming)

Encapsulation, Inheritance, Polymorphism
Encapsulation:

* It links code and data together

* It is achieved through object that contains same data and the functions to manipulate them

* It provides certin level of security to the data

* It provides information hiding
Inheritance:

* It supports reuseability

* It is a mechanism where use an existing object with a new object that has some unique characteristics

* It reduces complexity by using existing errorfree objects.

* Using inheritance we can create a general class that defines common properties. This class may be then inherited by other more specific classes each adding only those things that unique to the inheriting class

* A class that is inherited is known as base class

* A class that does inheriting is known as derived class
Polymorphysm:

* It is a mechanism that allows one interface to be used implement a number of task

* The specific action is detaermine by exact nature of the situation by the compiler

* There are two types of polymorphism occur

a) compile time polymorphism- types of arguments

b) run time polymorphism- same function can be execute

* classes have different functionality while sharing a common interface.
Class:

* It is the basic unit of Encapsulation

* It is a user defined data type that contains some data and function needed to manipulate the data

* Class is used to declare objects at that class
Object:

* It is variable of type class

* Class has no plysical existance but object has physical existance

* It is an instance of a class
Access Specifiers:

* Private- Local variable

* Public- Global variable

* Protected
Private:

* All the public and protected member of base become the private member of derived

* By default access is private

* Private cannot inherit without private and protected
Public:

* All the public member of base become public member of derived and all the protected member of base become protected member of derived
Protected:

* All the public and protected member of base become protected member of derived
Static Data member:

* A data member can be made a static member by adding the keyword static before variable declaration

* It is initialized to zero when first object is created

* Only one copy of the static data member exists and it is shared all the common objects of the same class

* It is used to maintain common data within the entire class

* We have to provide a global defination for the static data member outside the class

* A static data member exists before any object at its class is created

* Private members doesnot access

static int i;
Constructor:

* It is a special member function of a class where task is to initialize the objects of a class

* It is called automatically when an object of a class is created

– They have the same name as the class

– They donot have any return type not even void

– They should be declared in the public section

* In java initialize=0 and in C++ garvage
Default Construction:

* A constructor that doesnot accept any parameter is called default constructor
Parameterized Construction:

* By calling the constructor explicitly

* By calling the constructor implecitly
Destructor:

* Special type of member function whose tsk is to destroy the objects

* never takes any arguments and never returns any value

* Called automatically by the compiler
Difference between function overloading and function overriding:

* In function overloading the over loaded function should differ in the type or the number of parameters

* In function overridings the base class contain the virtual function and the derived classes redefined the same function till the function have same prototype

* A class containing virtual function is know as polymorphic class
Abstruct Class:

* Abstract classes are classes that contain one or more abstract methods

* An abstract method is a method that is declared, but contains no implementation

* Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods

– Abstruction: a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency
Interface:

* It is a collection of abstract methods

* It allows the computer to enforce certain properties on an object (class).

* A class implements an interface, thereby inheriting the abstract methods of the interface

* Along with abstract methods, an interface may also contain constants, default methods, static methods, and nested types.
MVC(Model, View & Controller)
SL NoDescription
Model:

* The model defines the rules for the process an application

* Responsible for both the application data and its behaviour
View:

* The view is responsible for formating the data returned by the model and presenting it to the user.
Controller:

* Responsible for determining how the application should respond based on events occuring typically user actions
PHP(Hypertext Preprocessor) and MySQL
SL NoDescription
Current PHP version: 7.2 but for server 5.6.30
* include(); (if not found) generated a warning, script will continue to execution

* require(); (if missing) generate a fatal error and script will stop

* These two function are used to create functions, header and footers or elements that will be reused on multiple pages
COOKIE: A cookie is a small file that server embeds on the users computer.

setcookie("user","Nayeem",time+3600);
SESSION: A session variable hold information about one single user in one application

unlink — Deletes a file, image, pdf etc
unlink — Deletes a file, image, pdf etc
PDO (PHP Data Object)

 
try{ 
$db = new PDO("dbtype:host=yourhost;dbname=yourdbname;charset=utf8","username","password"); 
$myinsecuredata=$_GET["id"]; 
$query=$db->prepare("Select * from table where id=?"); 
$query->excute(array($myinsecuredata)); 
}catch(PDOException  $e ){ 
echo "Error: ".$e; 
} 
$servername = "mysql.hostinger.com"; 
$database = "u266072517_name"; 
$username = "u266072517_user"; 
$password = "buystuffpwd"; 

// Create connection 

$conn = mysqli_connect($servername, $username, $password, $database); 

// Check connection 

if (!$conn) { 

    die("Connection failed: " . mysqli_connect_error()); 

} 
echo "Connected successfully"; 
mysqli_close($conn);
The mysqli extension has a number of benefits, the key enhancements over the mysql extension being:

-Prepared statements.

-Object oriented interface.

-Support for multiple statements.

-Embedded server support.
ORM framework:

Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages. This creates, in effect, a “virtual object database” that can be used from within the programming language. There are both free and commercial packages available that perform object-relational mapping, although some programmers opt to create their own ORM tools

* CakePHP’s built-in ORM specializes in relational databases
SQL Injection (SQLi) refers to an injection attack wherein an attacker can execute malicious SQL statements (also commonly referred to as a malicious payload) that control a web application’s database server

* SQL injection is a code injection technique, used to attack data-driven applications, in which nefarious SQL statements are inserted into an entry field for execution

* An SQL injection is a computer attack in which malicious code is embedded in a poorly-designed application and then passed to the backend database. The malicious data then produces database query results or actions that should never have been executed.

* A hacker might get access to user names and passwords in a database by simply inserting ” OR “”=” into the user name or password text box: ” or “”=”

SELECT * FROM Users WHERE Name =”” or “”=”” AND Pass =”” or “”=””

Option 1: Use of Prepared Statements (with Parameterized Queries)

Option 2: Use of Stored Procedures

Option 3: White List Input Validation

Option 4: Escaping All User Supplied Input
UNION removes duplicate records (where all columns in the results are the same), UNION ALL does not.
* npm , short for Node Package Manager, is two things: first and foremost, it is an online repository for the publishing of open-source Node.js projects; second, it is a command-line utility for interacting with said repository that aids in package

* npm is the package manager for JavaScript. It’s also the world’s largest software registry.
* The $_SERVER[“PHP_SELF”] is a super global variable that returns the filename of the currently executing script.

* The htmlspecialchars() function converts special characters to HTML entities.
Design Patterns
SL NoDescription
Singleton Pattern:

* Ensure that only one instance of a class is created.

* Provide a global point of access to the object
Factory Method Pattern:

* Defines an interface for creating objects, but let subclasses to decide which class to instantiate

* Refers to the newly created object through a common interface
Observer Pattern:

* Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Git
SL NoDescription
 
          $git config --global user.name "John Doe" 
          $git config --global user.email [email protected]This email address is being protected from spambots. You need JavaScript enabled to view it.  
          $git add .    [$git add -A][all removals, additions, and modifications in the working tree] 

          $git checkout -b nayeem  //create brunch 
          $git checkout nayeem 
          $git branch nayeem 
          $git branch -a 

          $git commit -m 'fixed some code' 
          $git checkout master 
          $git merge nayeem 
          $git push origin master 

          ctrl+O-------ctrl+C----------ctrl+X 

          /*=========working in master=============*/ 
            $git stash  // save local copy 
            $git pull origin master 
            $git stash pop            // merge local & server 
            $git add . 
            $git commit -m 'initial project version' 
            $git push origin master 
            /*=========working in master=============*/ 
            $git remote -v 
            $git remote rm origin 
            $git remote add staging ssh:// [email protected]This email address is being protected from spambots. You need JavaScript enabled to view it. /v1/repos/ntv_bn_web_staging 
            $git pull staging master 
            $git fetch staging master 
            $git push staging master 
          
tail -f /var/log/messages
© 2017 Md. Khurshed Alam Nayeem

Leave a Reply

Your email address will not be published. Required fields are marked *