Showing posts with label Interview Questions and Answers. Show all posts
Showing posts with label Interview Questions and Answers. Show all posts

Wednesday 25 July 2018

AWS interview questions and answers for 1 year experienced

AWS interview questions and answers for 1 year experienced

Question: What is the difference between Amazon S3 and Amazon EC2 instance?
Amazon S3: It is just storage service where you can upload photo, video, audio, pdf etc any type of files upto 5 terabytes (5Tb).
It store data as a object, you can't install any software like MS office, VLC player, Adobe etc.

You can import/export data from/to S3 and also can access via cloudfront.

EC2 instance: Launching a EC2 instance is similar a create virtual computer (windows, linux) where you can install software unlike S3. You can customize the configuration like volume(storage), RAM, CPU etc.


Question: How to copy files from one bucket to another?
  1. Login to SSH using ip address and ppk file.
  2. Make sure, it have AWS S3 access privilege
  3. Now just execute following command
    aws s3 sync s3://source-bucket s3://destination-bucket --exclude *.tmp
    



Question: Can we change the availability zone of an existing EC2 t1.micro instance?
No, you can not do.
for this, you need to launch new instance from existing instance.



Question: What is Availability Zones?
Amazon EC2 is hosted in world-wide.
These locations are composed of regions and Availability Zones.
Each region has multiple, isolated locations known as Availability Zones.


Question: How to move files directly from one S3 account to another?
Bucket Explorer works on Mac
S3 Browser works on windows.



Question: AWS Difference between a snapshot and AMI?
A snapshot is of an EBS volume where you save at a certain point of time.
An AMI is similar, but its for the EC2 instances themselves. you can create a AMI but can't do snapshot.


Question: What is the maximum length of a filename in S3?
1024 characters.



Question: How to move a domain from Godaddy to AWS Route 53? =>Login on your aws console
=>Click on Route 53
=>Create Hosted Zone
=>Select your new created host title
=>click "Go to Record Sets", take note of the nameservers;

=>Login on your Godaddy account
=>Select your domain
=>Go to Nameservers and click SetNameservers;
=>paste all the four you took from Go to Record Sets;


Question: How to transfer files between from AWS ec2 to S3
aws s3 cp myfolder s3://mybucket/myfolder --recursive



Question: How to transfer files between from S3 to EC2
aws s3 cp s3://mybucket/myfolder myfolder  --recursive



Question: Question: What is private hosted zone?
A private hosted zone is a container that holds information about how you want Amazon Route 53 to respond to DNS queries for a domain



Question: What is the AWS Storage Gateway service?
The AWS Storage Gateway service enables hybrid storage between on-premises environments and the AWS Cloud.


Tuesday 17 July 2018

AWS Tutorial Terminology page 7

AWS Tutorial Terminology page 7

Question: What is Amazon EBS Snapshots?
You can back up the data on your Amazon EBS volumes to Amazon S3 at any point of time knows as snapshots.

Snapshots are incremental backups, which means that only the blocks on the device that have changed after your most recent snapshot are saved.

When you delete a snapshot, only the data unique to that snapshot is removed.
Each snapshot contains all of the information needed to restore your data.



Question: What is enhanced networking on Linux?
Enhanced networking uses single root I/O virtualization (SR-IOV) to provide high-performance networking capabilities on supported instance types. SR-IOV is a method of device virtualization that provides higher I/O performance and lower CPU utilization when compared to traditional virtualized network interfaces.



Question: What is Spot Instances?
A Spot Instance is an unused EC2 instance that is available for less than the On-Demand price.
Because Spot Instances enable you to request unused EC2 instances at steep discounts, you can lower your Amazon EC2 costs significantly.


The hourly price for a Spot Instance is called a Spot price.The Spot price of each instance type in each Availability Zone is set by Amazon EC2, and adjusted gradually based on the long-term supply of and demand for Spot Instances.Your Spot Instance runs whenever capacity is available and the maximum price per hour for your request exceeds the Spot price.



Question: What is Amazon elastic map reduce?
Amazon EMR processes "big data" across a Hadoop cluster of virtual servers on Amazon Elastic Compute Cloud (EC2) and Amazon Simple Storage Service (S3).


Question: What is the AWS Storage Gateway service?
The AWS Storage Gateway service enables hybrid storage between on-premises environments and the AWS Cloud.


Question: Difference between Gateway cached volume and stored volume?
In the cached mode, your primary data is written to S3, while retaining your frequently accessed data locally in a cache for low-latency.
Whereas in the stored mode, your primary data is stored locally and your entire dataset is available for low-latency access while asynchronously backed up to AWS.


Question: What protection was on AWS Storage Gateway?
All data transferred between any type of gateway appliance and AWS storage is encrypted using SSL.
data stored by AWS Storage Gateway in S3 is encrypted server-side with Amazon S3-Managed Encryption Keys (SSE-S3).


Question: What is file gateway?
AWS Storage Gateway service that provides your applications a file interface to seamlessly store files as objects in Amazon S3, and access them, using industry standard file protocols.


Question:What is Amazon kinesis?
Amazon Kinesis is collect and process large streams of data records in real time.
The processed records can be sent to dashboards, used to send alerts and advertising strategies, or send data to a variety of other AWS services.


Question: What are benefits of Amazon Kinesis?
  1. Kinesis Video Streams to capture, process, and store video streams for analytics and machine learning.
  2. Kinesis Data Streams to build custom applications that analyze data streams using popular stream processing frameworks.
  3. Kinesis Data Firehose to load data streams into AWS data stores.
  4. Kinesis Data Analytics to analyze data streams with SQL.



Question: What is IOPS?
IOPS is the standard unit of measurement for I/O (Input/Output) operations per second.


Question: Amazon EBS General Purpose (SSD) volume type?
Elastic Block storage(EBS) General purpose (SSD) is default volume in EC2.
It is suitable for application from small to medium-sized databases, development and test environments, and boot volumes.


Question: What is Aws Data Pipeline?
AWS Data Pipeline is a web service that you can use to automate the movement and transformation of data.
With AWS Data Pipeline, you can define data-driven workflows, so that tasks can be dependent on the successful completion of previous tasks.



Question: What is Amazon Machine Images (AMI)?
An Amazon Machine Image (AMI) provides the information required to launch an instance, which is a virtual server in the cloud.


Monday 12 February 2018

React JS Interview Questions and Answers for beginner

React JS Interview Questions and Answers for beginner

Question: How to use JavaScript expressions in reactJS?
To use the expression in reactjs, you need to wrap the expression with with curly brackets {}.
For Example:
{1+1}
{2*2}
{30/3}
{i == 1 ? 'True!' : 'False'}


Question: How to use JavaScript Expressions in reactJS?

class App extends React.Component {
   render() {
      var myStyle = {
         fontSize: 40,
         color: '#FF0000'
      }
      return (
         <div>
<h1>
Header</h1>
</div>
);
   }
}
export default App;




Question: What is state in ReactJS?
State is the place where the data comes from.
We should try to make our state simple and minimize the number of stateful components.

class App extends React.Component {
   constructor(props) {
      super(props);
  
      this.state = {
         header: "This is Header from State",
         content: "This is Content from State"
      }
   }
   render() {
      return (
         <div>
<h1>
{this.state.header}</h1>
<h2>
{this.state.content}</h2>
</div>
);
   }
}



Question: How to Validating Props?

class App extends React.Component {
   render() {
      return ( 
         <div>
<h1>
 Hello, {this.props.name} </h1>
<h3>
Your Mobile: {this.props.propNumber}</h3>
<h3>
Address: {this.props.propString}</h3>
</div>
);
   }
}
App.propTypes = {
   name: PropTypes.string,
   propNumber: PropTypes.number,
   propString: PropTypes.string,
};
App.defaultProps = {
   name: 'Dear User',   
   propNumber: 9888888888,
   propString: "#8555, Sector 45D, Chandigarh"
}



Question: What is difference between setState and forceUpdate() and findDOMNode() in reactJS?
setState() It is used to update the state of the component.It will only add changes to the original state.
forceUpdate() It is used to forceUpdate the state of the component.It will only update to the original state.
findDOMNode() It is used to forceUpdate the state of the component.It will only update to the original state.


Question: Give working example of forceUpdate() in reactJS?

class App extends React.Component {
   constructor() {
      super();
      this.forceUpdateHandler = this.forceUpdateHandler.bind(this);
   };
   forceUpdateHandler() {
      this.forceUpdate();
   };
   render() {
      return (
         <div>
<button onclick="{this.forceUpdateHandler}">Click to Update</button>
            <br />
<h4>
Random number: {Math.random()}</h4>
</div>
);
   }
}



Question: How to use Loop in ReactJS?

var rows = [];
for (var i = 0; i &lt; numrows; i++) {
    rows.push(<objectrow key="{i}">);
}
return tbody(rows);  </objectrow>



Question: What is meaning of ... in ReactJS?
... is called Spread Attributes.
If you already have props as an object, and you want to pass it in JSX, you can use ... as a "spread" operator to pass the whole props object. For Example:

var parts = ['two', 'three'];
var numbers = ['one', ...parts, 'four', 'five'];



Question: How to set focus in reactJS?
You can use componentDidMount for the same.

class App extends React.Component{
  componentDidMount(){
    this.nameInput.focus();
  }
  render() {
    return(
      <div>
<input defaultvalue="Won't focus" />
        <input ref="{(input)" /> { this.nameInput = input; }} 
          defaultValue="will focus"
        /&gt;
      </div>
);
  }
}




Monday 8 January 2018

Zend Framework 2 Interview questions and answers for beginners

Zend Framework 2 Interview questions and answers for beginners

Question: What is module in ZF2?
Zend Framework2 uses a module system to organised your main application-specific code within each module.
Module is separated code from main which contain its own controllers, models, forms and views, along with configuration.
File Structure of module are as following
     /module
         /Album
             /config
             /src
                 /Album
                     /Controller
                     /Form
                     /Model
             /view
                 /album
                     /album



Question: What is Service manager?
The Service Manager is an implementation of the "Service Locator" design pattern.

Keys used for the service manager should be unique across all modules, you can do
this by prepended by the module name in keys.

Service manager configuration files are merged by the module manager.
The service manager lazily instantiate services when they are needed.



Question: How to invoke a class by service manager?
$serviceManager->setInvokableClass('user_mapper', 'User\Mapper\UserMapper');



Question: How to set the routing in Zend Framework2?
In Zend framwork2, routing is set in configuration file of same module.
File path: module.config.php (Full path: \module\Album\config\module.config.php)

Example of Routing in Zend Framework
'router' => array(
    'routes' => array(
        'album' => array(
            'type' => 'segment',
            'options' => array(
                'route' => '/album[/:action][/:id]',
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'id' => '[0-9]+',
                ),
                'defaults' => array(
                    'controller' => 'Album\Controller\Album',
                    'action' => 'index',
                ),
            ),
        ),
    ),
)

Following are the example of URL with above routing.
URL 1 : /album/index (Listing)
URL 2 : /album/add (Add Album)
URL 3 : /album/edit/10 (Edit Album )
URL 4 : /album/delete (Delete Album )

If you try to access url /album/hello, it will try to search helloAction in same controller.


Question: How to connect to mysql database in Zend Framework2?
  1. open global.php(/config/autoload/global.php)
  2. Add following before the "return array" String.
        $mysqlDbName='zf2';
        $mysqlDbHost='localhost';
        $mysqlDbUsername='root';
        $mysqlDbPassword='';
    
  3. replace the db array with following
         'db' => array(
             'driver'         => 'Pdo',
             'dsn'            => "mysql:dbname={$mysqlDbName};host={$mysqlDbHost}",
             'username' => $mysqlDbUsername,
             'password' => $mysqlDbPassword,         
             'driver_options' => array(
                 PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
             ),
         ),
        




Question: How to protect from Cross Site Scripting (XSS) vulnerabilities?
You need to use a in-built function whenever you print any data to browser.
    $htmlData='Hello World! How are you?';
    echo $this->escapeHtml($htmlData);



Question: How to direct from controller in Zend Framework2?
you can use redirect method for same.
    $this->redirect()->toUrl('/album/edit/1');



Question: How to permanent Redirect in Zend Framework2?
you can use redirect method for same.
    $this->redirect()->toUrl('/album/')->setStatusCode(301);



Question: How to temporary redirect in Zend Framework2?
you can use redirect method for same.
    $this->redirect()->toUrl('/album/')->setStatusCode(302);



Question: How to Change layout from controller in Zend Framework 2.0?
Add Following code in controller.
$this->layout('layout/custom'); //custom.phtml      
File path is : module\{module}\view\layout\custom.phtml Question: How to Change layout for module level in Zend Framework 2?
  1. Open the module.config.php of the module. (path: module\{module}\config\module.config.php)
  2. Add/Update Following code in view_manager array.
            'template_map' => array(
                'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml', //Setup the layout            
                'error/404'               => __DIR__ . '/../view/error/404.phtml',    //Setup the error        
            ),
    




Thursday 7 September 2017

Shell Scripting Interview Questions and Answer

Shell Scripting Interview Questions and Answer

Question: How to Check if a directory exist?
DIRECTORY='directoryname'
if [ -d "$DIRECTORY" ]; then
  echo "Directory is found"
else
  echo "Directory is Not found"
fi



Question: How to concatenate two string variable?
str1='Web'
str2='Technology'
fullStr="$str1 $str2";
echo $fullStr; #Web Technology 



Question: What do you mean by echo file1.txt > file2.txt?
> is used to redirect output.
echo file1.txt > file2.txt

It just redirect the output to file2.txt


Question: What do you means by 2>&1?
0 is stdin
1 is stdout
2 is stderr
>& is the syntax to redirect a stream to another file descriptor

So, Its saying display the error on stdout


Following two do same thing.
echo test 1>&2
OR
echo test >&2




Question: What is scp and why use? Give example?
SCP is used to copy the file/dir from one server to another server.
Example:
scp -r user@your.server.example.com:/path/to/source /home/user/destination/




Question: What is command to copy a file?
cp file1.txt \another\folder\file1.txt



Question: What is command to move a file?
mv file1.txt \another\folder\file1.txt



Question: How to count number of words in file?
 wc -w file.txt



Question: How to append in file from source file?
 cat sourcefile.txt >> destinationfile.txt
It will add the content in destinationfile.txt from sourcefile.txt



Question: How to search a string and then delete that line?
 sed '/removeTxt/d' ./file
It will remove the line having content removeTxt and print the output to console.



Question: How to set a variable to the output from a command?
 OUTPUT="$(ls -1)"
echo "${OUTPUT}"



Question: How to convert a string in lowercase?
a="Hello World!" 
echo "$a" | tr '[:upper:]' '[:lower:]' #hello world!



Question: What is use of export command?
export command is used to make the available of variable in child process.
Example 
export name=test

Now name variable will be accessible in child process.



Question: How to print date in yyyy-mm-dd format?
YYYY-MM-DD format
echo `date +%Y-%m-%d`
YYYY-MM-DD HH:MM:SS format
echo `date '+%Y-%m-%d %H:%M:%S'`



Question: How to reverse the lines?
tac file1.txt
It will revere the lines and display in console output.


Question: How to redirect output to file?
 ls -l 2>&1 | tee -a errorfile.txt

It will store error and output(both) in error_file.txt


Question: How to determine whether a Linux is 32 bit or 64 bit?
uname -m

Output
x86_64 ==> 64-bit kernel
i686   ==> 32-bit kernel



Question: How to compare two directories?
diff --brief -r dir1/ dir2/
diff -qr -r dir1/ dir2/



Question: When do we need curly braces around shell variables?
When you want to expand the variable (like foo) in the string.
For Example you want to make $foobar.
echo "${foo}bar"