Saturday, January 19, 2019

Compiler Design Tutorial ..!!

Compiler Design Tutorial

Compiler Tutorial


Compiler Design Tutorial provides basic and advanced concepts of Compiler. Our Compiler Tutorial is designed for beginners and professionals both.
Compiler is a translator that converts the high-level language into the machine language.

Our Compiler Tutorial includes all topics of Compiler such as introduction, grammar, parsing, syntax directed translation, symbol table, code optimization, code generation etc.


Introduction to Compiler

  • A compiler is a translator that converts the high-level language into the machine language.
  • High-level language is written by a developer and machine language can be understood by the processor.
  • Compiler is used to show errors to the programmer.
  • The main purpose of compiler is to change the code written in one language without changing the meaning of the program.
  • When you execute a program which is written in HLL programming language then it executes into two parts.
  • In the first part, the source program compiled and translated into the object program (low level language).
  • In the second part, object program translated into the target program through the assembler.
Compiler Introduction
Fig: Execution process of source program in Compiler

Compiler Phases

The compilation process contains the sequence of various phases. Each phase takes source program in one representation and produces output in another representation. Each phase takes input from its previous stage.
There are the various phases of compiler:
Compiler Phases
Fig: phases of compiler

Lexical Analysis:

Lexical analyzer phase is the first phase of compilation process. It takes source code as input. It reads the source program one character at a time and converts it into meaningful lexemes. Lexical analyzer represents these lexemes in the form of tokens.

Syntax Analysis

Syntax analysis is the second phase of compilation process. It takes tokens as input and generates a parse tree as output. In syntax analysis phase, the parser checks that the expression made by the tokens is syntactically correct or not.

Semantic Analysis

Semantic analysis is the third phase of compilation process. It checks whether the parse tree follows the rules of language. Semantic analyzer keeps track of identifiers, their types and expressions. The output of semantic analysis phase is the annotated tree syntax.

Intermediate Code Generation

In the intermediate code generation, compiler generates the source code into the intermediate code. Intermediate code is generated between the high-level language and the machine language. The intermediate code should be generated in such a way that you can easily translate it into the target machine code.

Code Optimization

Code optimization is an optional phase. It is used to improve the intermediate code so that the output of the program could run faster and take less space. It removes the unnecessary lines of the code and arranges the sequence of statements in order to speed up the program execution.

Code Generation

Code generation is the final stage of the compilation process. It takes the optimized intermediate code as input and maps it to the target machine language. Code generator translates the intermediate code into the machine code of the specified computer.
Example:
Compiler Phases 1


Compiler Passes

Pass is a complete traversal of the source program. Compiler has two passes to traverse the source program.

Multi-pass Compiler

  • Multi pass compiler is used to process the source code of a program several times.
  • In the first pass, compiler can read the source program, scan it, extract the tokens and store the result in an output file.
  • In the second pass, compiler can read the output file produced by first pass, build the syntactic tree and perform the syntactical analysis. The output of this phase is a file that contains the syntactical tree.
  • In the third pass, compiler can read the output file produced by second pass and check that the tree follows the rules of language or not. The output of semantic analysis phase is the annotated tree syntax.
  • This pass is going on, until the target output is produced.

One-pass Compiler


  • One-pass compiler is used to traverse the program only once. The one-pass compiler passes only once through the parts of each compilation unit. It translates each part into its final machine code.
  • In the one pass compiler, when the line source is processed, it is scanned and the token is extracted.
  • Then the syntax of each line is analyzed and the tree structure is build. After the semantic part, the code is generated.
  • The same process is repeated for each line of code until the entire program is compiled.

Bootstrapping

  • Bootstrapping is widely used in the compilation development.
  • Bootstrapping is used to produce a self-hosting compiler. Self-hosting compiler is a type of compiler that can compile its own source code.
  • Bootstrap compiler is used to compile the compiler and then you can use this compiled compiler to compile everything else as well as future versions of itself.
A compiler can be characterized by three languages:
  1. Source Language
  2. Target Language
  3. Implementation Language
The T- diagram shows a compiler SCIT for Source S, Target T, implemented in I.
Compiler Bootstrapping 1 Follow some steps to produce a new language L for machine A:
1. Create a compiler SCAA for subset, S of the desired language, L using language "A" and that compiler runs on machine A.
Compiler Bootstrapping 3 2. Create a compiler LCSA for language L written in a subset of L.
Compiler Bootstrapping 5 3. Compile LCSA using the compiler SCAA to obtain LCAA. LCAA is a compiler for language L, which runs on machine A and produces code for machine A.
Compiler Bootstrapping 10

Compiler Bootstrapping 11 The process described by the T-diagrams is called bootstrapping.


HTML Interview Questions..!!

HTML Interview Questions

A list of top frequently asked HTML interview questions and answers are given below.

1) What is HTML?

HTML stands for Hyper Text Markup Language. It is a language of World Wide Web. It is a standard text formatting language which is used to create and display pages on the Web. It makes the text more interactive and dynamic. It can turn text into images, tables, links. More details.

2) What are Tags?

HTML tags are composed of three things: an opening tag, content and ending tag. Some tags are unclosed tags.
HTML documents contain two things:
  • content, and
  • tags
When a web browser reads an HTML document, the browser reads it from top to bottom and left to right. HTML tags are used to create HTML documents and render their properties. Each HTML tags have different properties.

Syntax

  1. <tag> content </tag>  
Content is placed between tags to display data on the web page.
More details.

3) Do all HTML tags have an end tag?

No. There are some HTML tags that don't need a closing tag. For example: <image> tag, <br> tag. More details.

4) What is formatting in HTML?

The HTML formatting is a process of format the text for a better look and feel. It uses different tags to make text bold, italicized, underlined. More details.

5) How many types of heading does an HTML contain?

The HTML contains six types of headings which are defined with the <h1> to <h6> tags. Each type of heading tag displays different text size from another. So, <h1> is the largest heading tag and <h6> is the smallest one. For example:
  1. <h1>Heading no. 1</h1>    
  2. <h2>Heading no. 2</h2>    
  3. <h3>Heading no. 3</h3>    
  4. <h4>Heading no. 4</h4>    
  5. <h5>Heading no. 5</h5>    
  6. <h6>Heading no. 6</h6>    
More details.

6) How to create a hyperlink in HTML?

The HTML provides an anchor tag to create a hyperlink that links one page to another page. These tags can appear in any of the following ways:
  • Unvisited link - It is displayed, underlined and blue.
  • Visited link - It is displayed, underlined and purple.
  • Active link - It is displayed, underlined and red.
More details.

7) Which HTML tag is used to display the data in the tabular form?

The HTML table tag is used to display data in tabular form (row * column). It also manages the layout of the page, e.g., header section, navigation bar, body content, footer section. Here is the list of tags used while displaying the data in the tabular form:
TagDescription
<table>It defines a table.
<tr>It defines a row in a table.
<th>It defines a header cell in a table.
<td>It defines a cell in a table.
<caption>It defines the table caption.
<colgroup>It specifies a group of one or more columns in a table for formatting.
<col>It is used with <colgroup> element to specify column properties for each column.
<tbody>It is used to group the body content in a table.
<thead>It is used to group the header content in a table.
<tfooter>It is used to group the footer content in a table.

8) What are some common lists that are used when designing a page?

There are many common lists which are used to design a page. You can choose any or a combination of the following list types:
  • Ordered list - The ordered list displays elements in numbered format. It is represented by <ol> tag.
  • Unordered list - The unordered list displays elements in bulleted format. It is represented by <ul> tag.
  • Definition list - The definition list displays elements in definition form like in dictionary. The <dl>, <dt> and <dd> tags are used to define description list.
More details.

9) What is the difference between HTML elements and tags?


HTML elements communicate to the browser to render text.

10) What is semantic HTML?

Semantic HTML is a coding style. It is the use of HTML markup to reinforce the semantics or meaning of the content. For example: In semantic HTML <b> </b> tag is not used for bold statement as well as <i> </i> tag is used for italic. Instead of these we use <strong></strong> and <em></em> tags.

11) What is an image map?


Image map facilitates you to link many different web pages using a single image. It is represented by <map> tag. You can define shapes in images that you want to make part of an image mapping.

12) How to insert a copyright symbol on a browser page?

You can insert a copyright symbol by using &copy; or &#169; in an HTML file.

13) How to create a nested webpage in HTML?

The HTML iframe tag is used to display a nested webpage. In other words, it represents a webpage within a webpage. The HTML <iframe> tag defines an inline frame. For example:
  1. <!DOCTYPE html>    
  2. <html>    
  3. <body>    
  4. <h2>HTML Iframes example</h2>    
  5. <p>Use the height and width attributes to specify the size of the iframe:</p>    
  6. <iframe src="https://www.javatpoint.com/" height="300" width="400"></iframe>    
  7. </body>    
  8. </html>    

14) How do you keep list elements straight in an HTML file?

You can keep the list elements straight by using indents.

15) Does a hyperlink only apply to text?

No, you can use hyperlinks on text and images both. The HTML anchor tag defines a hyperlink that links one page to another page. The "href" attribute is the most important attribute of the HTML anchor tag.

Syntax

  1. <a href = "..........."> Link Text </a>  
More details.


16) What is a style sheet?

A style sheet is used to build a consistent, transportable, and well-designed style template. You can add these templates on several different web pages. It describes the look and formatting of a document written in markup language.

17) Can you create a multi-colored text on a web page?

Yes. To create a multicolor text on a web page you can use <font color ="color"> </font> for the specific texts you want to color.

18) Is it possible to change the color of the bullet?

The color of the bullet is always the color of the first text of the list. So, if you want to change the color of the bullet, you must change the color of the text.

19) Explain the layout of HTML?

HTML layout specifies a way in which the web page is arranged.

HTML Layouts

Every website has a specific layout to display content in a specific manner.
Following are different HTML5 elements which are used to define the different parts of a webpage.
  • <header>: It is used to define a header for a document or a section.
  • <nav>: It is used to define a container for navigation links
  • <section>: It is used to define a section in a document
  • <article>: It is used to define an independent, self-contained article
  • <aside>: It is used to define content aside from the content (like a sidebar)
  • <footer>: It is used to define a footer for a document or a section

20) What is a marquee?

Marquee is used to put the scrolling text on a web page. It scrolls the image or text up, down, left or right automatically. You should put the text which you want to scroll within the <marquee>......</marquee> tag. More details.

21) How many tags can be used to separate a section of texts?

Three tags are used to separate the texts.
  • <br> tag - Usually <br> tag is used to separate the line of text. It breaks the current line and conveys the flow to the next line
  • <p> tag - The <p> tag contains the text in the form of a new paragraph.
  • <blockquote> tag - It is used to define a large quoted section. If you have a large quotation, then put the entire text within <blockquote>.............</blockquote> tag.

22) How to make a picture of a background image of a web page?

To make a picture a background image on a web page, you should put the following tag code after the </head> tag.
  1. <body background = "image.gif">  
Here, replace the "image.gif" with the name of your image file which you want to display on your web page.


23) What are empty elements?

HTML elements with no content are called empty elements. For example: <br>, <hr> etc.

24) What is the use of a span tag? Give one example.

The span tag is used for following things:
  • For adding color on text
  • For adding background on text
  • Highlight any color text
Example:
  1. <p>  
  2. <span style="color:#ffffff;">  
  3. In this page we use span.  
  4. </span>  
  5. </p>  

25) What is the use of an iframe tag?

An iframe is used to display a web page within a web page.
Syntax:
  1. <iframe src="URL"></iframe>  
Example:
  1. <iframe src="demo_iframe.html" width="200px" height="200px"></iframe>  
Target to a link:
  1. <iframe src="http://www.javatpoint.com" name="iframe_a"></iframe>  

26) What are the entities in HTML?

The HTML character entities are used as a replacement for reserved characters in HTML. You can also replace characters that are not present on your keyboard by entities. These characters are replaced because some characters are reserved in HTML.

27) Why is a URL encoded in HTML?

An URL is encoded to convert non-ASCII characters into a format that can be used over the Internet because a URL is sent over the Internet by using the ASCII character-set only. If a URL contains characters outside the ASCII set, the URL has to be converted. The non-ASCII characters are replaced with a "%" followed by hexadecimal digits.

28) Does a <!DOCTYPE html> tag is a HTML tag?

No, the <!DOCTYPE html> declaration is not an HTML tag. There are many type of HTML e.g. HTML 4.01 Strict, HTML 4.01 Transitional, HTML 4.01 Frameset, XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1 etc. So, <!DOCTYPE html> is used to instruct the web browser about the HTML page.

HTML5 Interview Questions

Let's see a list of top HTML5 interview questions and answers.

29) What is the canvas element in HTML5?

The <canvas> element is a container that is used to draw graphics on the web page using scripting language like JavaScript. It allows for dynamic and scriptable rendering of 2D shapes and bitmap images. There are several methods in canvas to draw paths, boxes, circles, text and add images. For Example:
  1. <canvas id="myCanvas1" width="300" height="100" style="border:2px solid;">    
  2. Your browser does not support the HTML5 canvas tag.    
  3. </canvas>    
More details.

30) What is SVG?

HTML SVG is used to describe the two-dimensional vector and vector/raster graphics. SVG images and their behaviors are defined in XML text files. So as XML files, you can create and edit an SVG image with the text editor. It is mostly used for vector type diagrams like pie charts, 2-Dimensional graphs in an X, Y coordinate system.
  1. <svg width="100" height="100">    
  2.  <circle cx="50" cy="50" r="40" stroke="yellow" stroke-width="4" fill="red" />    
  3. </svg>   
More details.


31) What are the different new form element types in HTML 5?

Following is a list of 10 frequently used new elements in HTML 5:
  • Color
  • Date
  • Datetime-local
  • Email
  • Time
  • Url
  • Range
  • Telephone
  • Number
  • Search

32) Is there any need to change the web browsers to support HTML5?

No. Almost all browsers (updated versions) support HTML 5. For example Chrome, Firefox, Opera, Safari, IE.

33) Which type of video formats are supported by HTML5?

HTML 5 supports three types of video format:
  • mp4
  • WebM
  • Ogg
More details.

34) Is audio tag supported in HTML 5?

Yes. It is used to add sound or music files on the web page. There are three supported file formats for HTML 5 audio tag.
  1. mp3
  2. WAV
  3. Ogg
Let's see the code to play mp3 file using HTML audio tag.
  1. <audio controls>    
  2.   <source src="koyal.mp3" type="audio/mpeg">    
  3. Your browser does not support the html audio tag.    
  4. </audio>    
Instead of koyal.mp3, you can pass any mp3 file name.
More details.

35) What is the difference between progress and meter tag?

The progress tag is used to represent the progress of the task only while the meter tag is used to measure data within a given range. More details.

36) What is the use of figure tag in HTML 5?

The figure tag is used to add a photo in the document on the web page. It is used to handle the group of diagrams, photos, code listing with some embedded content.
  1. <p>The Taj Mahal is widely recognized as "the jewel of Muslim art in India and one of the universally admired masterpieces of the world's heritage."</p>    
  2. <figure>    
  3.   <img src="htmlpages/images/tajmahal.jpg" alt="Taj Mahal"/>    
  4. </figure>     
More details.

37) What is the use of figcaption tag in HTML 5?

The <figcaption> element is used to provide a caption to an image. It is an optional tag and can appear before or after the content within the <figure> tag. The <figcaption> element is used with <figure> element and it can be placed as the first or last child of the <figure> element.
  1. <figure>    
  2.   <img src="htmlpages/images/tajmahal.jpg" alt="Taj Mahal"/>    
  3. <figcaption>Fig.1.1 - A front view of the great Taj Mahal in Agra.</figcaption>    
  4. </figure>      
More details.

38) What is button tag?

The button tag is used in HTML 5. It is used to create a clickable button within the HTML form on the web page. It is generally used to create a "submit" or "reset" button. Let's see the code to display the button.
  1. <button name="button" type="button">Click Here</button>    
More details.

39) What is the use of details and summary tag?

The details tag is used to specify some additional details on the web page. It can be viewed or hidden on demand. The summary tag is used with details tag. More details.

40) What is datalist tag?

The HTML 5 datalist tag provides an autocomplete feature on the form element. It facilitates users to choose the predefined options to the users to select data.
  1. <label>    
  2.  Enter your favorite cricket player: Press any character<br />    
  3.  <input type="text" id="favCktPlayer" list="CktPlayers">    
  4.  <datalist id="CktPlayers">    
  5.  <option value="Sachin Tendulkar">    
  6.  <option value="Brian Lara">    
  7.  <option value="Jacques Kallis">     
  8.  <option value="Ricky Ponting">     
  9.  <option value="Rahul Dravid">     
  10.  <option value="Shane Warne">     
  11.  <option value="Rohit Sharma">     
  12.  <option value="Donald Bradman">     
  13.  <option value="Saurav Ganguly ">     
  14.  <option value="AB diVilliers">     
  15.  <option value="Mahendra Singh Dhoni">     
  16.  <option value="Adam Gilchrist">    
  17.  </datalist>    
  18. </label>     
More details.

41) How are tags migrated from HTML4 to HTML5?

No.Typical HTML4Typical HTML5
1)<div id="header"><header>
2)<div id="menu"><nav>
3)<div id="content"><section>
4)<div id="post"><article>
5)<div id="footer"><footer>

Header and Footer Example

HTML 4 Header and Footer:
  1. <div id="header">  
  2.   <h1>Monday Times</h1>  
  3. </div>  
  4. .  
  5. .  
  6. .  
  7. <div id="footer">  
  8.   <p>&copy; JavaTpoint. All rights reserved.</p>  
  9. </div>  
HTML 5 Header and Footer:
  1. <header>  
  2.   <h1>Monday Times</h1>  
  3. </header>  
  4. .  
  5. .  
  6. .  
  7. <footer>  
  8.   <p>© JavaTpoint. All rights reserved.</p>  
  9. </footer>  

Menu Example

HTML 4 Menu:
  1. <div id="menu">  
  2.   <ul>  
  3.     <li>News</li>  
  4.     <li>Sports</li>  
  5.     <li>Weather</li>  
  6.   </ul>  
  7. </div>  
HTML 5 Menu:
  1. <nav>  
  2.   <ul>  
  3.     <li>News</li>  
  4.     <li>Sports</li>  
  5.     <li>Weather</li>  
  6.   </ul>  
  7. </nav>  

42) If I do not put <!DOCTYPE html> will HTML 5 work?

No, the browser will not be able to identify that it is an HTML document and HTML 5 tags do not function properly..

43) What is the use of the required attribute in HTML5?

It forces a user to fill text on the text field or text area before submitting the form. It is used for form validation.
Example:
  1. Name: <input type="text" name="name" required>  

44) What are the new <input> types for form validation in HTML5?

The new input types for form validation are email, URL, number, tel, and date.
Example:

  1. <input type="email">  

HCL Technical basic Questions..!!

HCL Technical Questions


1) Does every class have a Constructor?

Yes, every class needs a Constructor. It may be Parameterized or Default. If the user does not define a constructor within a class, the default constructor is always included in that code.
The objective of Constructor is to initialize an object called object initialization. Constructors are mainly created for initializing an object.

2) How Java enable High Performance?

Java uses a Just-In-Time Compiler to enable high performance. Just-In-Time Compiler is a program that turns Java bytecode, which is a program that contains an instruction that must be interpreted into instruction that can be sent directly to the processor.

3) Why is java considered as dynamic?

It is designed to change the evolving environment. Java can carry an extensive amount of runtime information that can be used to verify and resolve access to the object at runtime.

4) What is joins in SQL?

Joins is nothing but connecting two or more table to fetch the record from two or more databases.

5) Can we have Private Constructor in Java?

Private Constructor is used if you do not want other class to instantiate the object. Private Constructor is used in Singleton design Pattern, Factory Method Design Pattern.

6) Differentiate Between Primary Key and Unique Key.

Primary Key Unique Key
1. In a Primary key, there should be only one primary key in a table. 1. In A Unique key, there can be more than one unique key in a table.
2. Primary key will block duplicate value and a null value. 2. Unique key will block duplicate value and accept a null value.

7) Differentiate between Method Overloading and Method Overriding.

Method Overloading Method Overriding
1. Method Overloading is used to gain the readability of the program. 1. Method Overriding is used to provide the specific implementation of the method that already provided by the superclass.
2. In the case of Method Overloading, the parameter must be different. 2. In the case of Method Overriding, the parameter must be equal.
3. Overloading happens at Compile time. 3. Overriding happens at runtime.
4. The Return type of method does not matter in case of method overloading it can be the same or different. 4. In the case of method Overriding, the return type must be the same.
5. you can overload a static, final and private method in Java 5. You cannot override a static, final and private method in Java.

8) What is the purpose of finalize () method in Java?

Finalize () method in java is a special method much like the main method in java. Finalize () method is called before garbage collector reclaims the object, its last chance for any object to perform clean up activity i.e. releasing any fixed order resources held, terminating connection if open etc.

9) Why can static method not override?

A static method cannot override because the static method is bound with class whereas instance method is bound with an object. Static method belongs to the class area and Instance method belong to the heap area.

10) What is singleton Class?

Singleton Class limited the number to one but allowing the flexibility to create more object if the situation changes.

11) Can we override java main method?

No, because main is a Static Method.

12) What is Class Cast Exception?

Class Cast Exception is thrown by java when you try to cast an object of one data type to another data type. Java allows us to cast the variable of one type to another as long as the casting happens between compatible data type.

13) Why polymorphism is used in Java?

The good reason for why polymorphism is a need in Java because the concept is extensively used in implementing inheritance. It plays an important role in allowing the object having a different internal structure to share the same external interface.

14) What is an Abstract class?

An Abstract class is one that is not used to create an object. It is only used as base class for the other class. The Abstract class is always public or friendly.
Syntax:
  1. public abstract class class_name  
  2.         {  
  3.             //class member  
  4.         }  

15) Can I have Private Constructor in Abstract Class?

Abstract Class can have Private Constructor But that class cannot be extended by another class. Alternatively, of adding a static inner class inside the Abstract Class and extends that Abstract Class.

HCL HR Interview Questions


1) Tell us about yourself.

This is the most common questions asked for both fresher's as well as experienced candidates. Well, you should answer this question in the following way:
Good Morning Sir/Mam
Hello, this is Ginni Bhatia. I belong to Kurukshetra. I have Completed MCA from Panipat Institute of Engineering and Technology College, in the specialization of Computer Science with an aggregate of 70% which is affiliated in Kurukshetra University. I have done B.Com (VOC) from Dayanand Mahila College with an aggregate of 65% which is also affiliated in Kurukshetra University. And I have also done Post Graduate Diploma in Computer Application (P.G.D.C.A) with an aggregate of 6.9(CGPA) from Lovely Professional University. My hobbies are singing a song, Dancing, Watching Movies and I love Web Designing. My strength is that I am Honest, Sincere, Responsible, and Positive. My weakness is that I am lazy. Talking about my achievements, I got certified in Singing level Competition. I have completed my Academic Project is ERP SYSTEM. My short-term goal is to be a part of your Company. My long-term goal is to be successful in every parameter of this company.
That's all about me sir.
Thanks for giving me time to introduce myself.

2) Why should we hire you?

As a Fresher, It is a great opportunity for me to work in a good company which helps me for the better career.

3) What is the difference between Confidence and Over-Confidence?

Confidence: - I can do it.
Overconfidence: - Only I can do it.

4) How do you feel about working nights and weekends?

Yes, if the Company needs me then I am ready to work at any time.

5) Can you work under pressure?

Yes, I can work under pressure; the pressure is nothing but encourages to do work sincerely.

6) What makes you angry?

I get angry when someone putting me down.

7) Where do you see yourself five years from now?

I can see myself growing with this company and reaching a position where I become valuable assets for this organization.

8) How much salary do you expect?

As a fresher, I would like to prefer Company norms.

9) Why did you leave your previous job?

Sir/mam, it's a career move. I have learned a lot from my past job.
But now, I am focused on a new challenge.

10) On the scale of one to ten, rate me as an interviewer.


Sir, you are more knowledgeable, more experienced than me I am not on a level to judge you.

INFOSYS Company Interview Question..!!

Infosys Interview Questions

Infosys is one of the India's leading technology company. Infosys Limited headquarters are in Bengaluru, Karnataka, India. Company trade name as "Infosys Technologies Limited." This business provides consulting, information technology and outsourcing services.
The recruitment and selection process of Infosys is geared towards matching between the candidate's aptitudes and company requirements.

Academic Conditions:

  • Minimum 60% Aggregate in 10th and 12th Mark sheet.
  • Minimum 65% and above in B.tech.

Company Recruitment and Selection Process

You have to crack three rounds to get selected in the interview. First round is an online test, which is logical answering and grammar. The second round is Technical round, which is technical answering, And the final and last round of the Infosys company is HR round, which is most common round in companies recruitment and selection process. Detailed Structure of the three rounds of company recruitment is given below.
First Round- Online Test: In the first round of Infosys recruitment and selection process Grammar and IQ is checked as per the company's requirements. Some frequently asked analytical questions are given below. Items may change but, grammar and logic will be the same. The difficulty level of this round is moderate. If you have a good IQ and communication skills, then you can easily crack this round.
Second Round- Technical Test: In the second step of recruitment and selection process Technical questions are asked. You can clear this test if you have good technical knowledge. Be careful while answering questions in the technical round, listen carefully to the interviewer because the technical round is the most difficult round among all the other rounds. Technical round is going to check your technical knowledge you had gained from your previous work experience.
Third Round- HR face to face Interview: If you completed the second round then you will be promoted to appear in the third round, which is straight face to face HR round. HR is a Human Resource Manager, who is going to talk to you and he is going to ask some questions about the company. I suggest you be cool while answering questions asked in HR round because he is not going to check your technical skill. HR round is not difficult if you have good communication skills. You only have to tell about yourself and the company.


First Round - Online Test Questions


Infosys English Interview Questions

1) We ________ a lovely three weeks in the south of Spain last year.

  • took
  • did
  • spent
  • passed

2) Your blue ________ are dirty.

  • Jeans
  • dress
  • shoes
  • shirt

3) Fiona is very angry ________ her boss's decision to sack several members of staff.

  • Against
  • about
  • for
  • by

4) Please don't forget to message me when you ________ home.

  • will get
  • get
  • are going to get
  • are getting

5) The teacher asked if ________ to bring our textbooks to class.

  • all we had remembered
  • we had all remembered
  • had all we remembered
  • had we all remembered

6) If you do well at school, you will have the ________ to go to university.

  • Luck
  • chance
  • result
  • hope

7) I must ________ for being so late.

  • Regret
  • apologise
  • excuse
  • pardon

8) I've only got a ________ money in the bank.

  • Less
  • little
  • few
  • bit

9) When Shikha was a little girl, she used to ________ small glass animals.

  • Pick
  • collect
  • play
  • choose

10) You ________ to ring Aunt Jean to thank her for her present.

  • Should
  • must
  • could
  • ought

11) What ________ you going to do in your summer holidays?

  • Are
  • do
  • have
  • will

12) Julie immediately jumped ________ the pool, but it was too cold for me to swim there.

  • On
  • up
  • in
  • for

13) Would you like to ________ shopping with me this afternoon?

  • Go
  • do
  • make
  • get

14) I'm very ________ - could I have a glass of water, please?

  • Empty
  • thirsty
  • hungry
  • dirty

Infosys Logical Reasoning Questions


The list of logical questions that have been asked in the Infosys interview is given below:

1) Compound interest 1200 become Rs. 1348.32 in 2 years. Find the increasing rate?

  1. 6%
  2. 7.5%
  3. 8%
  4. 9%

2) Look at this series: 4, 2, 1, (1/2), (1/4), what number should come next?

  1. (1/3)
  2. (1/8)
  3. (2/8)
  4. (1/16)

3) Which one word does not belong to the other words?

  1. parsley
  2. basil
  3. dill
  4. mayonnaise

4) Which word does not belong with the other words?

  1. inch
  2. ounce
  3. centimeter
  4. yard

5) Select the word which does not belong with the other words?

  1. tyre
  2. steering wheel
  3. engine
  4. car

Infosys Aptitude Questions


The list of aptitude questions that have been asked in the Infosys interview are given below:

1) X fires 5 shots to Y's 3, but X kills only once in 3 shots while Y kills once in 2 shots. When Y has missed 27 times, X has killed:

  1. 30 birds
  2. 60 birds
  3. 72 birds
  4. 90 birds

2) Gaurav's age after 15 years will be 5 times his age 5 years back. What is the present age of Gaurav?

  1. 10 years
  2. 18 years
  3. 20 years
  4. Cannot be determined
  5. None of these

3) The statement I: The government has recently fixed the fees for professional courses, which are much lower than the fees charged in the last year offered by the unaided institutions

Statement 2: The parents of the students launched a severe agitation last year protesting against the high fees charged by the unaided institutions.

  1. The statement First is the cause and statement Second is its effect
  2. Statement Second is the cause and statement First is its effect
  3. Both the statements First and Second are independent causes
  4. Both the statements First and Second are effects of independent causes

4) A is as much younger than B. B as he is older than C. If the sum of the ages is 50 years. What is the difference between the ages of B and A's?

  1. 1 year
  2. 2 years
  3. 25 years
  4. Data inadequate
  5. None of these

Infosys Technical Interview Questions


1) What is polymorphism?

Polymorphism is a concept by which we can perform a single action in different ways. Polymorphism is derived from two Greek words: poly and morphs. The word "poly" means many and "morphs" means forms. So polymorphism means many forms.

2) Explain the functionality of linked list.

A linked list consists of two parts. Information part and the link part. In the single linked list, first node of the list is marked by a unique pointer named as start and this pointer points to the first element of the list, and the link part of each node consists of a pointer pointing to the next node, but the last node of the list has null pointer identifying the last node. The linked list can be traversed easily with the help of Start pointer.

3) What is normalization of databases, joins, and keys?

Normalization is also known as the process of organizing data in a DBMS efficiently without any loss of data.
Advantages of the normalization process are as follows:
First is eliminating redundant data and ensuring data dependencies make sense. It reduces the amount of space that the database consumes and ensure that data is logically stored.
Join:
This clause is used in DBMS to combine rows from two or more tables, based on a related column between them.
Keys:
Keys are a crucial part of the relational database model. They are used to identify and establish relationships between tables. They are also used to uniquely determine each record or row of data in a table.
Key:
A Key can be a single attribute or a group of attributes acting as a key.

4) What is inheritance?

In, object-oriented programming, inheritance is a mechanism based on classes.
Inheritance refers to inheriting the data members and properties of a parent class to a child class. A class which is derived from another class is often called as a sub-class, and the class from which the child class is derived is known as super-class or parent class.

5) What are the different types of inheritance?

Types of Inheritance:
  • Single inheritance
  • Multiple Inheritance
  • Multi-level Inheritance
  • Multi-path Inheritance
  • Hierarchical Inheritance
  • Hybrid Inheritance

6) Demonstrate the process of inheriting variable of one class to other class?

  1. //Base Class  
  2. class A   
  3. {   
  4. public int a;  
  5.   
  6. }  
  7. //Derived Class  
  8. class B : A  
  9. {  
  10. a=15;  
  11.   
  12. }  

7) What are the loops statements?

To execute a block of statement several times in a program depending upon the conditional statement loops are used.
Infosys Interview Questions
The basic structure of a loop is given above in the diagram. For each successful execution of the loop, the conditional statement should be checked. If the conditional statement is true, then the loop will be executed. If the conditional statement is false, then the loop will be terminated.

8) Difference between classes and interface?

The difference between classes and interface are listed below:
  • The instance of the class can be created by creating its object, whereas interfaces cannot be instantiated as all the methods in the interface are abstract and do not perform any action, There is no need for instantiating an interface.
  • A class is declared using class keyword whereas an interface is declared using interface keyword.
  • The members of the class can have access specifier such as public, protected, and private but members of the interface cannot have the access specifier, all the members of the interface is declared as public because the interface is used to derive another class. There will be no use of access specifies inside the members of an interface.
  • The methods inside the class are defined to perform some actions on the fields declared in the class whereas interface lacks in declaring in fields, the methods in an interface are purely abstract.
  • A class can implement any number of the interface but can only extend one superclass, whereas interface can extend any number of interfaces but cannot implement any interface.
  • A class can have a constructor defined inside the class to declare the fields inside the class, whereas interface doesn't have any constructor defined because there are no fields to be initialized.

9) What is software development life-cycle? Also, explain the waterfall model.

SDLC is a process followed for developing and enhancing software project. It consists of a detailed plan for developing, maintaining a specific software. The life cycle defines a methodology process for improving the quality of software and the overall development process.
In "The Waterfall" model, the whole process of software development is divided into separate phases. In this Waterfall model, typically, the outcome of one phase acts as the input for the next phase sequentially.

10) What are the four basic principles of OOPS?

The four basic principles of Object-Oriented Programming System are listed below:
  1. Abstraction
  2. Inheritance
  3. Encapsulation
  4. Polymorphism.

11) What are the conditional statements?

The conditional statements can alternatively be called a conditional expression also. Conditional statements are the set of rules which were executed if a particular condition is true. It is often referred to an if-then statement because if the condition is true, then the statement is executed.

12) What is Database Management System?

A Database Management System is a software system is used for creating and managing databases. DBMS make it possible for the end user to create and maintain databases. DBMS provides an interface between the end user/application and the databases.

13) List different advantages of DBMS.

Improved data sharing.
The list of several advantages of Database Management System:
  • Improved data security.
  • Better data integration.
  • Minimized data inconsistency.
  • Improved data access.
  • Improved decision making.
  • Increased end-user productivity.

14) What do you mean by Object-Relational DBMS?

The object-relational database (ORD) is a database management system (DBMS) that are composed of both an object-oriented database (OODBMS) and a relational database (RDBMS). ORD supports the essential components of an object-oriented database model in its schemas and the query language used, such as inheritance, classes, and objects.
An object-relational database is also known as an object-relational database management systems (ORDBMS).

15) What is database Schema?

It is a set of formulas (sentences) called integrity constraints imposed on a database.

16) What is an IC? What is its importance?

IC refers to integrated circuits sets of electronic circuits on single flat piece semiconductor material, and usually, silicon is used. The integration of a large number of tiny transistors into a small chip results in circuits that are smaller in size and faster than those discrete electronic components. The importance of integrated circuits than the separate electronic components is integrated circuits are smaller in size, faster, low costs than discrete electronic components.

17) Write a program to check whether the input number is a perfect number or not.

  1. #include <stdio.h>  
  2.   
  3. int main()Improved data sharing.  
  4. {  
  5.     int number, remainder, sum = 0, i;  
  6.   
  7.     printf("Enter a Number\n");  
  8.     scanf("%d", &number);  
  9.     for (i = 1; i < number ; i=i+1)  
  10.     {  
  11.         remainder = number % i;  
  12.         if (remainder == 0)  
  13.         {  
  14.             sum += i;  
  15.   
  16.         }  
  17.     }  
  18.     if (sum == number)  
  19. {  
  20.         printf("Number is perfect number");  
  21. }  
  22.     else  
  23. {  
  24.         printf("Number is not a perfect number");  
  25. }  
  26.     return 0;  
  27. }  

18) Tell me something about DSN?

A Data Source Name as the name suggests it is the logical name for Open Database Connectivity to refer to other information that is required to access data. For a connection to an ODBC data source Microsoft SQL Server database.

19) What is the difference between a Clustered-index and a non-clustered-index?

Clustered Index - Only one per table is allowed
Faster to read than non clustered because the data is physically stored in index order
Non-Clustered Index - Can be used many times in a table
Quicker for inserting and updating operations than a clustered index

20) Difference between C & embedded C.

C Language
  1. C is a type of the computer programming language. C was initially developed by Dennis Ritchie in AT&T Bell Labs between 1969 and 1973. It has a free-format program source code. C is a general-purpose programming language.
  2. C is generally used for desktop computers
  3. C can use the resources of a desktop PC like memory, OS, etc.
  4. Compilers for C (ANSI C) typically generate OS dependent executables.
Embedded C
  1. Embedded C is the set of language extensions for the C Programming language. It was released by the C Standards committee. Through the Embedded C extensions, the C Standards committee hoped to address the commonality issues that exist between C extensions for different embedded systems.
  2. Embedded C is for micro-controller based applications.
  3. Embedded C is used with the limited resources, such as RAM, ROM, I/Os on an embedded processor.
  4. Embedded C requires compilers to create files to be downloaded to the micro-controllers/microprocessors where it needs to run.

21) What is a pointer in C? What is its use?

The pointer is a particular variable which holds the address of another variable of the same type. Pointers can be of any data type and structure are allowed in C programming language. Pointer variable stores the address of another variable of the same data type as the value of the pointer variable.
Following are the uses of pointers:
  • To point a variable in the memory.
  • Pointers are used to traverse the linked list.
  • To point out a structure.

22) Different between a session and a socket?

The Socket is the Combination of Ip address, and Port Number and the session is a Logical Connectivity between the source and destination.

23) What is a null pointer?

The null pointer is the pointer with no reference to any location of the memory.
A null pointer contains zero as its value which means pointer is empty and not pointing to anywhere in the memory. Null pointers can be used further in the program to initialize the address of the memory location with the same data type of the pointer.

Note: Pointers can only point to the variable having the same datatype. If the data type of pointer and datatype of pointing variable is different, then the pointer will not work.


24) What is a Real-Time OS?

A real-time operating system is an operating system which acts as an interface between hardware and user. This system guarantees a specific capability within a specified time. For example, an operating system is designed to ensure that a specific object was available for a robot on an assembly line.

25) Difference between TCP and UDP.

TCP UDP
Connection-orientated protocol Connectionless protocol
Segment sequencing. No sequencing.
Acknowledge sequencing No windowing and retransmission.
Reliable transmission protocol. Unreliable transmission protocol.

26) Write a c program to swap two numbers without using a temporary variable.

  1. void swap(int &i, int &j)  
  2. {  
  3. i=i+j;  
  4. j=i-j;  
  5. i=i-j;  
  6. }  

27) Which functions are used for memory allocation in C/C++

The Function calloc() allocates a memory area, and the length will be the product of its parameters(it has two parameters). It fills the memory with ZERO's and returns a pointer to the first byte of the memory. If it fails to locate enough space, Then it returns a NULL pointer.
The function malloc() allocates a memory area, and length will be the value entered as a parameter. (it has one parameter). It does not initialize memory area free() used to free the allocated memory(allocated through calloc and malloc), in other words, this used release the allocated memory new also used to allocate memory on the heap and initialize the memory using the constructor delete also used release memory allocated by new operator

28) Write output of the program?

  1. int i=10;  
  2. printf("%d%d%d",i,++i,i++);  
  3. Answer = 10 12 12  

29) What is a virtual function and what is the pure virtual function?

Virtual function:- In order to achieve polymorphism, function in base class is declared as virtual, By declare virtual we make the base class pointer to execute the function of any derived class depends on the content of pointer (any derived class address).
Pure Virtual Function:- This is a function used in base class, and its definition has to be provided in a derived class, In other pure virtual function has no definition in the base is defined as:
  1. virtual void fun()=0;  
That means this function not going to do anything, In case of the pure virtual function derived function has to implement the pure virtual function or redeclare it as the pure virtual function

30) What are WPF-WCF?

WPF/WCF application, need in .NET 3.0 Framework. This application will cover the following concepts:
  • WCF(Windows Communication Foundation)
  • The new service orientated attributes
  • The use of interfaces
  • The use of callbacks
  • Asynchronous delegates
  • Creating the proxy
  • WPF( Windows Presentation Foundation )
  • Styles
  • Templates
  • Animations
  • Databinding
  • Multithreading a WPF application

31) Difference between the EXE and the DLL file extension?

The term EXE is a short-term of the word executable as it identifies the file as a program. Whereas, DLL stands for Dynamic Link Library, which commonly contains functions and procedures that can be used by other programs.

32) Scenarios in which the web application should be used and scenarios in which desktop application should be used?

Scenarios in which web application used are listed below:
  • Cost effective development
  • Accessible anywhere
  • Easily customizable
Scenarios in which desktop application should be used are listed below:
  • Desktop application usually has more control.
Safe for computationally expensive software that needs to communicate directly with the OS.
The desktop application is often offline and does not need an Internet connection to function compared to a web application.

33) What is an array?

An array is a group of elements used to store a group of related data of the same data type.
The array uses index number to identify each element in an array.

34) Inner join Vs. Outer join?

Infosys Interview Questions

35) What are the SQL tables?

A table is a set of related data in a structured format in the database. A table is consists of rows and columns.

36) What is the difference between array and pointer?

An array is the group of similar elements having the same data type, whereas the pointer is a variable pointing to some data type in the memory. Arrays can only contain the elements of similar data type whereas pointer variable is used to point to any data type variable.

37) How abstraction and encapsulation complementary?

Abstraction and encapsulation are complementary because in object-oriented programming classes can only be abstracted if it is encapsulated. The abstraction focuses on the observable behavior of an object, whereas encapsulation focuses on the implementation that gives rise to this behavior.

38) How is modularity present in C++?

Modularity is the concept explained in oops concept, and it was introduced with class and objects in c++. Functions, classes, structures implements modularity in C++.

39) Define the structural difference between the b-tree index and bitmap?

Btree
This tree structure was developed by Bayer and McCreight in 1972.
This tree structure is a height-balanced m-way search tree. A B-tree of the order m can be defined as an m-way search tree.
It is made up of branch nodes and leaf nodes.
Bitmap
It consists merely of bits for every single distinct value. It uses a string of bits to locate rows in a table quickly. Used to index low cardinality columns.

40) What do you mean by platform independence?

The platform independence refers to the ability of programming language or a platform that you implement on one machine and use them on another machine without or minimal changes. There are two types of platform independence, source platform independence, and binary platform independence. For example, Java is a binary platform independent language whereas c and c++ are source platform independence languages because java uses java virtual machine to run their programs but c and c++ use compilers to convert the source code to executable machine language.

41) Differentiate between Char and Varchar in DBMS?

Char and Varchar both are the datatypes in DBMS. Char and varchar both datatypes are used to store characters up to 8000. The only point of difference between the Char and Varchar is Char fixed length string datatype whereas Varchar, as the name suggests, is a variable length character storing data type.
For example, char(7) will take 7 bytes of memory to store the string, and it also includes space. Whereas varchar will take variable space, which means that it will only take that much of space as the actual data entered as the data of varchar data type.

42) Do you know about the different level of languages?

The different levels of programming languages were listed below:
  • Low-level Language- Language which is understandable by machine is often known as machine language (binary language). It is challenging to read and doing code in this language by humans directly.
  • Assembly level language- Some mnemonics are used which reduce the complexity of the program.
  • Middle-level Language- This language is not so tricky as the assembly language, but it still requires the knowledge of computer hardware which makes it little difficult to program. For Example C and C++ programming languages.
  • High-level language- Its right to say, this level of the programming language is the highest level of the programming language in the technology. These types of programming languages do not require the knowledge of the hardware. This level of the programming language is elementary to learn by the humans. For Example Java, PHP, Perl, Python, etc.

43) What is the word used for the virtual machine in JAVA? How is it implemented?

The word "Java Virtual Machine known as JVM in short" is used for the virtual machine in Java. This word is implemented from the java runtime environment (JRE).

44) List the areas in which data structures are applied extensively?

The list of areas where data structures are applied extensively are listed below:
  • Compiler Design
  • Operating System
  • Database management System
  • Numerical analysis
  • Artificial Intelligence
  • Simulation
  • Statistical analysis package

45) Difference between Class and Struct.

A structure and a class differ a lot as a structure has limited functionality and features as compared to a class. A class can be defined as the collection of related variables and functions encapsulated in a single structure whereas a structure can be referred to as an user-defined datatype for processing its operations. A keyword "Struct" is used for declaration of Struct Where a keyword "class" is used for the declaration of a class in the programming language. Default access specifier of the class is private whereas default access specifier of the struct is public. The purpose of the class is data abstraction and further inheritance whereas the use of the struct is generally, Grouping of data. General usage of the struct is a small amount of data whereas general usage of the class is to store a large amount of data.

46) What is the difference between a white box, black box, and gray box testing?

White Box Testing Black Box Testing Gray Box Testing
Internal programming fully known. Internal programming is not known. Internal programming is partially known.
Tester knows the internal working of the application. The knowledge of the internal working of the application is not required. Internal working of the application is partially known.
White box testing is also known as glass, open box, clear box, structural testing, or code-based testing. Black box testing is also known as a closed box, data-driven, and functional testing. Gray box testing is also known as translucent testing.
Performed by tester and developers. Performed by the end user and also by tester and developers. Performed by the end user and also by tester and developers.
The tester can design test data. Testing is based on external expectation. By high-level database diagrams and data flow diagrams.
Most exhaustive and time-consuming. Least time consuming and exhaustive. Partially time-consuming and exhaustive.
Data domain and internal boundaries can be better tested. Performed by the trial, and error method. Data domains and the internal boundaries can be tested if known.
Not suited for algorithm testing. Not suited for algorithm testing. Suited for algorithm testing.

47) Describe three levels of data abstraction? Which layer is at the user end?

The three levels of data abstraction are listed below:
  1. Physical level: This is the lowest level of database abstraction describes how the data are stored.
  2. Logical level: This level is the next higher level than the physical level of database abstraction, which represents the data stored in the database and what relationship among those data.
  3. View level: This is the highest level of database abstraction describes only part of the entire database.
No doubt, View level layer of database abstraction is at the user end.

48) Difference between 'Macro' and 'ordinary' definition.

  • Macro takes parameters whereas the ordinary definition does not.
  • Based on the parameter values to macro, it can result in different value at runtime. Ordinary definition value remains same at all place at runtime.
  • Macro can be used for conditional operations whereas the definition cannot.
  • Using macro one can achieve inline functionality in C, i.e., a macro can be a function performing simple operations. This is not possible using definitions.

49) Write the program in C language to swap two numbers without using a third variable.

  1. #include<Stdio.h>  
  2. #include<conio.h>  
  3. void main()  
  4. {  
  5. int i,j;  
  6. printf("Enter the value of i: \n");  
  7. scanf("%d",&i);  
  8. printf("Enter the value of j: \n");  
  9. scanf("%d",&j);  
  10. printf("Value of i before swap:%d \n",i);  
  11. printf("Value of j before swap:%d \n",j);  
  12. i=i+j;  
  13. j=i-j;  
  14. i=i-j;  
  15. printf("Value of i after swap:%d \n",i);  
  16. printf("Value of j after swap:%d \n",j);  
  17.   
  18. }  

50) What are IPv4 and IPv6? Differentiate between them.

IPv4 IPv6
IPv4 contains 32 bit Ip address. IPv6 contains 128 bit IP address.
The older version of the IP address. The newer version of the IP address.
generates 4.29 x 109 unique network addresses produces 3.4 x 1038 addresses

51) What is the difference and similarity between C and C++?

C and C++ both use the same syntax. C++ is the extension of the C language. C and C++ both have same compilers. C++ language consists of classes and objects whereas there are no classes and objects available in the C language. C++ is an OOP based programming whereas C is not OOPS based programming language.

52) What are the different modulation techniques?

The two types of modulation techniques are an analog and digital modulation. Further analog modulation is subdivided into amplitude, frequency and phase modulation.

53) Differentiate between 'a' and "a."

"a" is string value whereas 'a' is a character value in c programming language.

54) What is the pre-processor?

The pre-processor is just a text substitution tool, and they instruct the compiler to do required pre-processing before actual compilation.

55) Write a program in c language to check whether the input number is a prime number or not.


  1. #include<conio.h>  
  2. #include<stdio.h>  
  3.    
  4. int main()  
  5. {  
  6. int num,i;  
  7. int flag=0;  
  8. printf("Enter the number:");  
  9. printf("\n");  
  10. scanf("%d",&num);  
  11.     for(i=2;i<num;i++)  
  12.     {  
  13.         if(num%i==0)  
  14.         {  
  15.         flag++;  
  16.         }  
  17.     }  
  18.     if(flag>0)  
  19.     {  
  20.     printf("number is not a prime number\n");  
  21.     }  
  22.     else  
  23.     {  
  24.     printf("Entered number is an prime number\n");  
  25.     }  
  26. return;  
  27. }