Infosys interview pyqs with solutions for freshers
10 September 2024

Infosys interview pyqs with solutions for freshers. 100% Selection

By deepblogs.net
Spread the knowledge

Table of Contents

Infosys interview pyqs with solutions for freshers:

Here are Infosys interview pyqs with solutions for freshers, you can practise them(Infosys interview pyqs with solutions for freshers) for your interview for Infosys(Infosys interview pyqs with solutions for freshers).

Infosys: (Infosys interview pyqs with solutions for freshers)

Infosys Limited is an Indian multinational information technology company that offers business consultinginformation technology, and outsourcing services. Founded in Pune, the company is headquartered in Bangalore.

Q)Explain four major OOP concepts in Java. (Infosys interview pyqs with solutions for freshers)

Solution:

Here’s a brief explanation of the four major OOP concepts in Java:

  1. Encapsulation: Bundles data and methods that operate on the data into a single unit (class) while restricting access to the internal details. Access is controlled through access modifiers like private, protected, and public.
  2. Inheritance: Allows a new class to inherit properties and behavior (fields and methods) from an existing class. This promotes code reuse and establishes a natural hierarchy.
  3. Polymorphism: Enables objects to be treated as instances of their parent class, allowing one interface to be used for a general class of actions. This can be achieved through method overloading (compile-time) and method overriding (runtime).
  4. Abstraction: Hides the complex implementation details and shows only the essential features of an object. It’s achieved using abstract classes and interfaces in Java.

Q)How method overloading is different from method overriding? (Infosys interview pyqs with solutions for freshers)

Solution:

Method Overloading

  • Definition: Method overloading occurs when two or more methods in the same class have the same name but different parameter lists (different number, types, or order of parameters).
  • When it happens: At compile-time (also known as compile-time polymorphism or static polymorphism).
  • Purpose: It allows different ways to perform a similar operation, depending on the inputs.
  • Example: (JAVA)

class MathOperations {
int add(int a, int b) {
return a + b;
}

double add(double a, double b) {
return a + b;
}
}

Method Overriding

  • Definition: Method overriding occurs when a subclass provides a specific implementation for a method that is already defined in its superclass. The method in the subclass must have the same name, return type, and parameter list as the method in the superclass.
  • When it happens: At runtime (also known as runtime polymorphism or dynamic polymorphism).
  • Purpose: It allows a subclass to provide a specific implementation of a method that is already provided by its superclass, allowing behavior to be customized for the subclass.
  • Example: (JAVA)

class Animal {
void sound() {
System.out.println(“Animal makes a sound”);
}
}

class Dog extends Animal {
@Override
void sound() {
System.out.println(“Dog barks”);
}
}

Q)What is polymorphism? (Infosys interview pyqs with solutions for freshers)

Solution:

Polymorphism in Java is the ability of a single method or object to take many forms. It allows one interface to be used for different data types or objects. There are two types:

  1. Compile-Time Polymorphism (Method Overloading): Same method name with different parameters within the same class.
  2. Runtime Polymorphism (Method Overriding): A subclass provides a specific implementation of a method already defined in its superclass, allowing dynamic method invocation based on the object type at runtime.

Q)What is normalization of databases, joins, and keys? (Infosys interview pyqs with solutions for freshers)

Solution:

Normalization of Databases:

Normalization is the process of organizing a database to reduce redundancy and improve data integrity. It involves dividing a database into smaller tables and defining relationships between them. The goal is to ensure that each table contains data related to a single topic, minimizing duplicate data and avoiding update anomalies.

Joins:

Joins are used in SQL to combine rows from two or more tables based on a related column between them. The main types are:

  • Inner Join: Returns only the rows with matching values in both tables.
  • Left Join (Outer Join): Returns all rows from the left table and the matched rows from the right table. Unmatched rows from the right table return null.
  • Right Join (Outer Join): Returns all rows from the right table and the matched rows from the left table. Unmatched rows from the left table return null.
  • Full Join (Full Outer Join): Returns all rows when there is a match in either left or right table.

Keys:

  • Primary Key: A unique identifier for each record in a table. It ensures that no duplicate records exist and each record is uniquely identifiable.
  • Foreign Key: A field in one table that links to the primary key of another table, establishing a relationship between the two tables.
  • Candidate Key: A column or set of columns that can uniquely identify any database record without referring to any other data. A table can have multiple candidate keys, but only one can be the primary key.
  • Composite Key: A key that consists of two or more columns used together to uniquely identify a record in a table.

Q)Explain the functionality of linked list. (Infosys interview pyqs with solutions for freshers)

Solution:

A linked list is a data structure consisting of a sequence of elements called nodes, where each node contains two parts:

  1. Data: The value stored in the node.
  2. Pointer (Reference): A link to the next node in the sequence.

Key Points:

  • Singly Linked List: Each node points to the next node, forming a chain. The last node points to null, indicating the end of the list.
  • Doubly Linked List: Each node has two pointers, one pointing to the next node and another to the previous node, allowing traversal in both directions.
  • Advantages:
    • Dynamic size: Can easily grow or shrink as needed.
    • Efficient insertion/deletion: Adding or removing elements can be done without reorganizing the entire structure.
  • Disadvantages:
    • No direct access: To access an element, you must traverse the list from the beginning.
    • Extra memory: Requires additional memory for storing pointers.

Q)Can we implement multiple inheritances in Java? (Infosys interview pyqs with solutions for freshers)

Solution:

In Java, multiple inheritance is not supported directly through classes to avoid ambiguity and complexity (e.g., the Diamond Problem). However, it can be achieved through:

  • Interfaces: A class can implement multiple interfaces, allowing it to inherit multiple behaviors. This is how Java provides a form of multiple inheritance.

Q)What are DDL and DML commands in SQL? (Infosys interview pyqs with solutions for freshers)

Solution:

DDL Commands:

  • Definition: DDL commands are used to define and manage database structure.
  • Common Commands:
    • CREATE: Creates a new table, database, index, or view.
    • ALTER: Modifies an existing database object, like adding or removing columns in a table.
    • DROP: Deletes an entire table, database, or other database objects.
    • TRUNCATE: Removes all records from a table but keeps the structure for future use.

DML Commands:

  • Definition: DML commands are used to manipulate data within existing tables.
  • Common Commands:
    • INSERT: Adds new records to a table.
    • UPDATE: Modifies existing records in a table.
    • DELETE: Removes records from a table.
    • SELECT: Retrieves data from one or more tables.

Q)What is inheritance? (Infosys interview pyqs with solutions for freshers)

Solution:

Inheritance in Java is an OOP concept where a new class (subclass or child class) derives properties and behaviors (fields and methods) from an existing class (superclass or parent class). This promotes code reuse and establishes a hierarchical relationship between classes.

Q)Demonstrate the process of inheriting variable of one class to other class? (Infosys interview pyqs with solutions for freshers)

Solution:

To demonstrate inheritance of a variable from one class to another in Java:

  1. Define the Parent Class with a variable.
  2. Create a Child Class that extends the Parent Class and inherits its variables.

Example: (Java)

// Parent class
class Parent {
// Variable in parent class
protected int number = 10;
}

// Child class inheriting from Parent class
class Child extends Parent {
void display() {
// Accessing inherited variable
System.out.println(“Number: ” + number);
}
}

// Main class to test inheritance
public class TestInheritance {
public static void main(String[] args) {
Child obj = new Child();
obj.display(); // Outputs: Number: 10
}
}

In this example:

  • The Parent class has a variable number.
  • The Child class inherits the number variable from the Parent class and uses it in its display method.

Q)What are the loops statements? (Infosys interview pyqs with solutions for freshers)

Solution:

Loop statements in Java are used to repeatedly execute a block of code based on a condition. The main types are:

  1. for Loop: Executes a block of code a specific number of times, with initialization, condition, and increment/decrement expressions.
  2. while Loop: Repeats a block of code as long as a given condition is true.
  3. do-while Loop: Executes a block of code at least once and then repeats it as long as the condition remains true.

Q)Distinguish between classes and interfaces in Java. (Infosys interview pyqs with solutions for freshers)

Solution:

Classes:

  • Definition: A class is a blueprint for creating objects, encapsulating data (fields) and methods (functions) that operate on the data.
  • Instantiation: Can be instantiated to create objects.
  • Inheritance: Supports single inheritance (a class can extend only one class).
  • Access Modifiers: Can have access modifiers (private, protected, public) for fields and methods.
  • Constructors: Can have constructors to initialize objects.
  • State: Can maintain state through instance variables.

Interfaces:

  • Definition: An interface is a contract that defines a set of abstract methods (methods without a body) that implementing classes must provide.
  • Instantiation: Cannot be instantiated directly.
  • Inheritance: Supports multiple inheritance (a class can implement multiple interfaces).
  • Access Modifiers: Methods in an interface are implicitly public and abstract; fields are implicitly public, static, and final.
  • Constructors: Cannot have constructors.
  • State: Cannot maintain state directly (except static final variables).

Q)Why indexing in SQL is useful ? (Infosys interview pyqs with solutions for freshers)

Solution:

Indexing in SQL is useful because it:

  • Improves Query Performance: Speeds up data retrieval by allowing the database to quickly locate and access rows based on index keys, reducing the need for full table scans.
  • Enhances Sorting and Filtering: Accelerates sorting and filtering operations on indexed columns.
  • Optimizes Join Operations: Enhances performance of join queries by quickly matching rows from different tables.

Q)Differentiate between TRUNCATE and DELETE commands in SQL. (Infosys interview pyqs with solutions for freshers)

Solution:

TRUNCATE:

  • Function: Removes all rows from a table, but keeps the table structure for future use.
  • Performance: Generally faster because it deallocates data pages rather than logging individual row deletions.
  • Transaction Logging: Minimal logging, making it less resource-intensive.
  • Rollback: Can be rolled back if used within a transaction.
  • Triggers: Does not activate triggers.

DELETE:

  • Function: Removes specified rows from a table based on a condition or all rows if no condition is provided.
  • Performance: Slower for large datasets due to row-by-row logging.
  • Transaction Logging: Fully logged, which allows for more granular control.
  • Rollback: Can be rolled back if used within a transaction.
  • Triggers: Activates triggers on row deletions.

Q)What are the different types of inheritance? (Infosys interview pyqs with solutions for freshers)

Solution:

The different types of inheritance in Java are:

  1. Single Inheritance
  2. Multiple Inheritance (through interfaces)
  3. Multilevel Inheritance
  4. Hierarchical Inheritance
  5. Hybrid Inheritance (a combination of multiple and hierarchical inheritance, typically through interfaces)

Q)What is software development life-cycle? Also, explain the waterfall model. (Infosys interview pyqs with solutions for freshers)

Solution:

Software Development Life Cycle (SDLC):

The SDLC is a process for planning, creating, testing, and deploying software. It provides a systematic approach to software development with stages including:

  1. Requirement Analysis: Gathering and analyzing requirements.
  2. Design: Creating architectural and detailed design.
  3. Implementation: Coding the software.
  4. Testing: Verifying and validating the software.
  5. Deployment: Releasing the software to users.
  6. Maintenance: Performing updates and fixing issues post-deployment.

Waterfall Model:

The Waterfall Model is a linear and sequential SDLC approach where each phase must be completed before the next one begins. It includes:

  1. Requirements: Define what the software should do.
  2. Design: Outline the software architecture and design.
  3. Implementation: Develop the software based on the design.
  4. Testing: Check the software for defects.
  5. Deployment: Release the software to users.
  6. Maintenance: Make necessary updates and fixes.

Q)What is the left outer join and the right outer join in SQL? (Infosys interview pyqs with solutions for freshers)

Solution:

Left Outer Join:

  • Definition: Returns all rows from the left table and the matched rows from the right table. If there is no match, NULL values are returned for columns from the right table.
  • Usage: Ensures all records from the left table are included in the result.

Right Outer Join:

  • Definition: Returns all rows from the right table and the matched rows from the left table. If there is no match, NULL values are returned for columns from the left table.
  • Usage: Ensures all records from the right table are included in the result.

Q)What is stored procedure? (Infosys interview pyqs with solutions for freshers)

Solution:

A stored procedure is a precompiled collection of SQL statements and optional control-flow logic that is stored in a database. It is executed on the server side and can be called from applications or other procedures. Stored procedures help in:

  • Encapsulation: Grouping multiple SQL statements into a single procedure.
  • Reusability: Reusing code without rewriting SQL statements.
  • Performance: Reducing network traffic and improving performance through precompilation.
  • Security: Controlling access to data and operations by providing controlled execution.

Thank You For visiting our website. In our website, you get more such educational content so don’t forget to allow the notification for more such content.

For more visit: https://deepblogs.net/category/educational-courses/