Accenture Interview Questions

Accenture Interview Questions

Accenture is the world’s leading management, outsourcing, technology & Information Technology services company. Accenture involves various business sectors, like CRM (Customer Relationship Management), business strategies, supply chain management, outsourcing, and technologies. It was started in the year 1989 in the name of Andersen Consulting. After getting separated from its parent company, Arthur Andersen, in 2001, it changed its name. Accenture’s global headquarters is located in Dublin, Ireland. Its branches are in approximately 200 cities in 50 countries worldwide, including India.

Accenture Interview Questions

Accenture’s primary domains are IT, Media and Technology, Health and public, Financial Services, Products and resources, and communication. Accenture operates a wide range of services and solutions within the mentioned domains. It operates in areas like strategy, digital, technology, consulting, and operations. Apart from providing the best services and solutions, Accenture also focuses on cost reduction for clients and outsources technology functions. Freshers Jobs will guide you with Accenture interview questions.

Interview Process

Given below are the academic criteria to apply for an Accenture interview.

  • Applicants can apply if they hold a graduate degree in a pertinent field and have achieved an average score of 65% or higher.
  • Candidates must have cleared all the subjects and should have no backlogs.
  • The education gap taken by the candidate should be a year at maximum.

Generally, the Recruitment process at Accenture consists of 3 rounds.

  1. Online Assessment Test
  2. Technical Interview
  3. HR Interview

Interview Round

Given below are the levels of the Accenture interview process.

  • Online Assessment Test: The first round in the Accenture recruitment process is the Online Assessment Test. It is a little tricky compared to other rounds since it consists of elimination. This round is crafted to assess the candidates’ cognitive function and ability. The questions in this round will be about Quantitative Aptitude, Logical Reasoning, and Verbal Ability. The candidates must answer a specific number of questions in the given time to be selected.

Online Assessment Test

  • Technical interview: If candidates get selected for the online assessment test, they will be invited to the next round. The next round is the Technical interview, which tests the candidates’ problem-solving abilities and coding skills. To clear this round, the candidates should have fundamental knowledge of data structures, algorithms, and other computer science-related subjects such as OS, DBMS, CN, etc. The candidates will be tested according to the job role they applied for.
  • HR Interview: The HR Interview is the last round in the Accenture interview process. This is the round where the interview panel determines whether to hire the specific candidate. In this round, the candidate’s personality traits are assessed. The questions will be relevant to your resume, like self-introduction, educational qualification, hobbies, strengths and weaknesses, salary expectations, interests, passion, etc. In this round, candidates can also be asked questions regarding the company. While other rounds are conducted to evaluate a candidate’s skills, knowledge, and accomplishments, the main objective of an HR Interview is to evaluate the personality, background, and ability to handle the job role to decide whether the candidate is the desired candidate for the job role and the company.

Accenture Interview Questions

  1. Define the Diamond problem in Java.

The “Diamond problem” generally occurs in the case of multiple inheritance. Java lacks support for multiple inheritance. So, diamond problems occur in Java when you try to implement multiple inheritance. When a class implements two interfaces that contain methods with identical signatures, it results in compiler uncertainty because the compiler cannot determine which method to call. This situation is often likened to a diamond shape in its structure, earning it the name “Diamond problem.” As a consequence, a compilation error occurs.

  1. What is a classifier in Python?

A classifier is an algorithm that utilizes a set of features to forecast the category of an input element. It generally depends on training data, which comprises extensive datasets used to educate the algorithm or machine learning model to develop an understanding of the connection between input variables and categories. Classifiers are predominantly utilized within the domains of machine learning and supervised learning.

For instance, a classifier can be employed to anticipate the category of soap based on its attributes, often referred to as “features.” These features might encompass aspects like visual appearance, color, etc.

  1. Define XML.

XML stands for Extensible Markup Language. It is a markup language that provides rules for document encoding formatting so that humans and machines can easily understand it. It is also used to describe the data, develop information formats, and share structured data online.

  1. What is a class in C++?

In C++, a class is a pre-defined data type or structure declared with keywords containing data and functions.

  1. What is an object in C++?

An object is an instance of a class. No memory is allocated during a class defined. In contrast, memory is allocated during a class instantiation.

  1. What is Operator overloading?

Operator overloading permits a single operator name or system for several operations.

  1. Justify why the Java language platform is independent. 

Java achieves platform independence by utilizing a virtual machine. The Java language and its entire APIs are compiled into bytecodes, which inherently possess platform independence. The virtual machine is responsible for handling the variations in bytecode execution across different platforms.

  1. Define an auto keyword in C.

In C, an auto keyword is used to specify a storage duration. When a user generates an auto variable, it will contain an automatic storage duration. These objects are called local variables. In C, all variables in functions are local by default.

  1. Justify why exceptions occur.

Exceptions occur for several reasons, like invalid user input, code errors, system failures, loss of network connection, insufficient memory for running an application, memory issues with another program, a program trying to divide by 0, or a user trying to access unavailable files.

  1. Explain the purpose of the “super” and “this” keywords in Java.
  • Super keyword: The super keyword helps reference instances of the superclass in Java. Since super keywords are reserved in Java, they can’t be used as an identifier. It can also be used to invoke superclass members like methods and constructors.
  • This keyword: This keyword is utilized to refer to an instance of the current class. Like the super keyword, it is also reserved in Java, so it can’t be used as an identifier. It can also refer to an object of the current class to invoke a constructor for the current class. This process is done to pass an argument in the method or constructor call to return the object of the current class.

If you want more job opportunities, explore Fresher Jobs in Pune.

  1. Define normalization in the database.

Normalization/ data normalization/ database normalization is a process of arranging data in the database to reduce data redundancy and enhance its integrity. Data can be organized in tables and columns. Users can also define a relationship between these tables or columns using data normalization.

Normalization Forms

Following are the 5 normalization forms.

  • First Normal Form (1NF)
  • Second Normal Form (2NF)
  • Third Normal Form (3NF)
  • Boyce-Codd Normal Form (BCNF)
  • Fourth Normal Form (4NF)
  • Fifth Normal Form (5NF)
  1. Can multiple interfaces be implemented in a single Java class?

Yes, it is possible to incorporate multiple interfaces within a single class. In Java, the concept of multiple inheritance is realized by having a class implement multiple interfaces. During the implementation process, each interface is listed and separated by commas.

Syntax:

public class ClassName implements Interface1, Interface2, …, InterfaceN {

// Code

}

Example:

public class Student implements X, Y {

// Code

}

In this example, the class Student implements the X and Y interfaces.

  1. What are Pandas in Python?

Panda is a Python software library that is open-source and used for manipulating and analyzing data. It offers sufficient data structures and operations, like numerical tables and time series modifications. Panda can handle various types of files and is an essential learning tool.

Attributes of Pandas

Given below are a few attributes or methods provided by Pandas:

  • Axes (): Axes() returns a row axis label list.
  • Empty (): Empty() returns true if the series is empty; otherwise, it returns false.
  • Size (): Size() returns the count of elements in the underlying data.
  • Values (): Values() returns the series as an array.
  • Head (): Head() returns the n rows from the beginning of a data frame or series.
  • Tail (): Tail() returns the n rows from the end of a data frame or series.
  1. What is a friend() function in C++?

A friend() function can access private and protected members of another class. For example, it can access the class where it is declared a friend. We can declare a friend() function using the friend keyword.

Syntax:

class class_name;

class FriendClass {

public:

return_type function_name(class_name &obj);

};

class class_name {

// Statements

friend return_type FriendClass::function_name(class_name &obj);

};

  1. What functions should be used for memory allocation in context to C?

Memory allocation and deallocation are usually performed using 2 key functions: malloc() and free().

Malloc () (Memory Allocation):

Malloc() stands for “memory allocation”. It allocates a block of memory of a specified size in bytes. The function returns a pointer to the first byte of the allocated memory block, or it returns NULL if the allocation fails due to insufficient memory. You should always check if the malloc() call were successful by verifying if the returned pointer is not NULL.

Example of memory allocation using malloc():

int *ptr;

ptr = (int *)malloc(sizeof(int));

if (ptr == NULL) {

// Memory allocation failed.

// Handle the error appropriately.

}

Free() (Memory Deallocation):

Free() is used to deallocate or release previously allocated memory using malloc() or related functions. It helps prevent memory leaks by returning the allocated memory to the system to be reused. After calling free(), the pointer is no longer valid and should not be accessed.

Example of memory deallocation using free():

free(ptr);

ptr = NULL; // Set the pointer to NULL after freeing the memory to avoid using a dangling pointer.

  1. Define a Pointer and mention its uses in C.

In C, a pointer saves the memory address of another variable. It “points to” the memory location where a value is stored rather than containing the actual value itself.

Pointers are a basic concept in C and provide several essential uses, including

  • Dynamic Memory Allocation.
  • Passing Parameters to Functions.
  • Arrays and Data Structures.
  • String Manipulation.
  • Pointer Arithmetic.
  • Efficient Memory Management.
  • Accessing Hardware.
  • Efficient Data Passing.
  • Function Pointers.
  • Memory Management and Cleanup.

Detailed Accenture Interview Questions

  1. Explain Exception Handling. 

Exception Handling responds to an unwanted event during a program’s runtime. This process prevents system crashes from all those unwanted events. Without this process, exceptions can disrupt the normal flow of the program’s execution. Exception handling provides a structured way to detect, handle, and recover from such unexpected situations, ensuring that the program doesn’t crash and can continue functioning as intended.

  • Throwing an Exception: In the Code, when an exceptional condition is encountered, you can “throw” an exception. This means creating an exception object encapsulating the error or exceptional condition information.
  • Catching an Exception: To handle exceptions, you write Code that “catches” or “handles” the exception. The exception handler is a block of Code designed to respond to the specific type of exception thrown.
  • Exception Types: Exceptions are typically organized into various types or classes, each representing a different error or exceptional situation. For example, in Java, you have exceptions like NullPointerException or FileNotFoundException.
  • Try-Catch Blocks: Exception handling is often implemented using try-catch blocks. The code that throws an exception is placed within a try block, and the code to handle the exception is placed within one or more catch blocks.

try {

//code that throws an exception

} catch (ExceptionType1 e1) {

// Handle ExceptionType1

} catch (ExceptionType2 e2) {

// Handle ExceptionType2

}

  • Finally Block: A finally block is a statement that is performed in certain programming languages whether or not an exception is thrown. It is frequently applied to tidying up tasks, such as resource releases or file closures.
  • Exception Propagation: Exceptions have the ability to go up the call stack. An exception can be propagated to the calling method, which can manage it or spread it further, if a method is unable to handle it.
  • Custom Exception Classes: You can make custom exception classes in various programming languages to represent particular failures or extraordinary circumstances that are particular to your application.
  1. Define the OOP concept.

OOPs is a programming paradigm that organizes software design and development around the concept of objects. It is based on the following fundamental principles:

OOPs Principles

  • Objects: Objects are the building blocks of an object-oriented system. Each object represents a specific entity, concept, or thing in the real world. Objects can have attributes (data) and methods (functions) that operate on the data.
  • Classes: A class is a blueprint for generating objects. It defines the structure & behavior of objects of a particular type. Objects are instances of classes.
  • Encapsulation: The idea of encapsulation is the grouping together of an object’s methods (functions) and data (attributes) into a single unit (the object). To avoid directly altering an object’s internal state, it offers access control and data masking.
  • Inheritance: Inheritance allows a new class (a subclass or derived class) to inherit the attributes and methods of an existing class (a superclass or base class). It supports code reuse and the creation of hierarchies of related classes.
  • Polymorphism: It is possible to treat objects of different classes as objects of a single parent class thanks to polymorphism. It enables the use of objects of derived classes through their base class interface. Polymorphism promotes flexibility and extensibility in software design.
  • Abstraction: It simplifies complex reality by modeling classes based on their shared essential characteristics or behavior. It allows developers to center on what an object does rather than how it does it.

Object-oriented programming is widely employed in software development because it promotes modularity, reusability, and code maintainability. It provides an organized approach to designing and building complex software systems by modeling them as collections of interacting objects, each responsible for specific tasks and functionality. OOP is the basis for many modern programming languages, including Java, C++, Python, and C#.

  1. What is the purpose of the static keyword in Java?

In Java, the static keyword is referred to as a non-access modifier used to manage the memory.

Objects can share the static property. During object creation, no separate copies of static members are generated.

It is unnecessary to generate the class instance to access the static members. It is possible to access them using class names directly.

Static keywords can be utilized with variable, block, method, and nested classes to manage the memory.

  • Static variable: When declaring a variable with the static keyword, a copy of the variable is generated, and all the class objects will share the same variable (a class that belongs to the static variable).
  • Static block: A static block is utilized to initialize static data members. A Java class can contain a group of statements executed exactly once when the class is initially loaded into the Java Virtual Machine (JVM).
  • Static Method: When a method is declared using the static keyword, it is referred to as a static method. The main() method is an instance of a static method. Static methods have certain limitations, such as being able to call other static methods directly and access static data directly.
  • Static class: A static class can only be created as nested. A nested static class does not require a reference to the outer class in which it is defined. However, a static class cannot access non-static members of the outer class.
  1. What is the memory allocation process in C?

Memory allocation in C involves reserving a portion based on the program’s needs.

Types of Memory Allocation

There are two primary types of memory allocation in C:

  • Static Memory Allocation: Static memory allocation occurs at the beginning of the program. Memory allocation is fixed, and the allocated memory size remains constant throughout execution. It utilizes a stack for memory management.
  • Dynamic Memory Allocation: Dynamic memory allocation takes place during runtime. Memory size can be specified as needed during program execution. It utilizes a heap data structure for memory management. Memory can be allocated & deallocated from the heap. Dynamic memory allocation is commonly used with pointers. It provides flexibility in managing memory during runtime, making it a valuable tool in C programming.

There are four pre-defined functions for dynamic memory allocation:

  • Malloc (): Allocates memory.
  • Calloc(): Allocates and initializes memory to zero.
  • Realloc(): Resizes memory previously allocated by malloc() or calloc().
  • Free(): Deallocates memory, returning it to the heap.

For more job opportunities at Accenture, visit Accenture Jobs for Freshers.

  1. Explain memory deallocation in C++.

Memory deallocation consists of releasing memory that was allocated when the program was executed. This process prevents memory leaks and efficiently manages system resources. It is explained below.

Dynamic Memory Allocation: In C++, it is possible to allocate memory dynamically using operators like new, new[], malloc, or calloc. During runtime, these operations will reserve a memory block on the heap (free store). The allocated memory is associated with a pointer variable.

Memory Usage: The program will use the memory that was allocated for storing data, like objects, arrays, or other structures that are allocated dynamically. This memory is usually used for variables with a longer lifespan than local (stack) variables.

Deallocation: Memory deallocation is vital to avoid leaks and free up memory for reuse. The programmer is responsible for explicitly deallocating dynamically allocated memory when it’s not needed anymore. There are respective deallocation operations for each allocation method:

  • For memory allocated with new, use delete.
  • For arrays allocated with new[], use delete[].
  • For memory allocated with malloc, use free.

Releasing Resources: In addition to freeing memory, it is the user’s responsibility to release any associated resources, like closing files, network connections, or database connections, as part of proper resource management.

Nullify Pointers: After deallocation, it’s advisable to set the pointer to nullptr or assign it to a new address. This process ensures that you don’t accidentally access the memory after it has been freed, which can lead to undefined behavior. For instance,

Coding:

int* dynamicArray = new int[10]; // Dynamic memory allocation

// Use dynamicArray for storing data

// Deallocate memory when no longer needed

delete[] dynamicArray;

dynamicArray = nullptr; // Nullify the pointer

It’s crucial to note that C++11 introduced smart pointers, like std::shared_ptr and std::unique_ptr, which can automatically manage your memory deallocation. These smart pointers are recommended as they help prevent common memory management issues and make your code more robust. Memory will be deallocated when it’s no longer needed, as it is based on the RAII concept (Resource Acquisition Is Initialization).

Coding-Based Accenture Interview Questions

  1. Define runtime polymorphism and explain how it is achieved in Java.

Runtime polymorphism, or dynamic binding or method dispatch, dynamically resolves the call to an overridden method during runtime rather than compiling time. In the realm of Java programming, runtime polymorphism is accomplished through the mechanism of method overriding. When a subclass (child class) defines a method with the same name, return type, and parameters as a method in its superclass (parent class), this new method in the subclass effectively replaces, or “overrides,” the one in the superclass. This concept and practice are commonly referred to as method overriding.

For example, consider the following scenario with one superclass, “Vehicle,” and three subclasses, “Bike,” “Bus,” and “Car.” These subclasses extend the superclass and override its “print()” method. When we call the “print()” method using a reference variable of the “Vehicle” class (i.e., the parent class), the subclass method is invoked at runtime. This is because it references an object of the subclass, which takes precedence over the subclass method. The Java Virtual Machine (JVM) determines method invocation, making it a case of runtime polymorphism.

Coding:

class Vehicle {

void print() {

System.out.println(“Inside Vehicle”);

}

}

class Bike extends Vehicle {

void print() {

System.out.println(“Inside Bike”);

}

}

class Bus extends Vehicle {

void print() {

System.out.println(“Inside Bus”);

}

}

class Car extends Vehicle {

void print() {

System.out.println(“Inside Car”);

}

}

public class TestVehicles {

public static void main(String args[]) {

Vehicle a = new Vehicle();

Vehicle b = new Bike(); // Upcasting

Vehicle m = new Bus(); // Upcasting

Vehicle r = new Car(); // Upcasting

a.print();

b.print();

m.print();

r.print();

}

}

Output:

Inside Vehicle

Inside Bike

Inside Bus

Inside Car

  1. Define lambda expressions in Java.

A Lambda expression is a self-contained function that can be defined without needing to be encapsulated within a class. This feature was introduced in Java 8. Lambda expressions are utilized to provide implementations for interfaces, exceptionally functional interfaces. They eliminate the need to redeclare a method for implementation, allowing developers to write the implementation code directly. This significantly reduces the amount of code required. It’s vital to note that Lambda expressions are treated as functions, and the compiler does not generate a class file. They are commonly used for straightforward callback functions, event listeners, or functional programming, especially when working with the Java Streams API.

The syntax for Lambda Expression is:

(parameters) -> expression

parameters represent the input arguments, which can be zero or more.

-> (arrow token) separates the parameters from the expression.

Expression is the single expression or statement that the lambda expression will evaluate and return.

Here is a Java program that demonstrates the use of lambda expressions while implementing a custom functional interface:

Sample Coding:

// Define a functional interface with a single abstract method

interface MyFunctionalInterface {

int performOperation(int a, int b);

}

public class LambdaExample {

public static void main(String[] args) {

// Putting the functional interface into practice with a lambda expression

MyFunctionalInterface addition = (x, y) -> x + y;

MyFunctionalInterface subtraction = (x, y) -> x – y;

// Perform operations using the lambda expressions

int result1 = addition.performOperation(5, 3);

int result2 = subtraction.performOperation(8, 4);

System.out.println(“Addition Result: ” + result1);

System.out.println(“Subtraction Result: ” + result2);

}

}

  1. Differentiate between “var++” and “++var”.

“var++” and “++v” are helpful to increase the value of the “var” variable. “Var++” will evaluate the expression, and its value will increase by 1. This process is known as post-incrementation of a variable. Whereas “++var” will increase the variable’s value by one and then evaluate the expression. So, this process is known as the pre-incrementation of a variable. For example,

Coding:

#include <stdio.h>

int main() {

int x, y;

x = 7;

y = 1;

printf(“%d %d\n”, x++, x); // Outputs 7 8

x = 7; // Reset x to 7

printf(“%d %d”, ++x, x); // Outputs 8 8

return 0;

}

In the above Code, we explicitly reset the variable x’s initial value before demonstrating the ++x and x++ behavior. This way, the output reflects the individual behavior of each operation without the influence of the previous statement.

  1. Define the getch() function in a C++ program and explain how it is different from the getche() function.

The getch() function is a built-in library function in C++ that is utilized to capture a single input character from the keyboard, and it will pause the screen until it receives a character from the standard input. This function doesn’t need any parameters and is declared in the “conio.h” header file.

Coding: 

#include <iostream>

using namespace std;

int main() {

char ch;

cout << “Enter the character: ” << endl;

cin >> ch;

return 0;

}

Both functions will keep the output screen paused until a key is pressed on the keyboard. The main distinction is that getch() receives the character without displaying it on the screen, while getche() displays it as pressed.

  1. What is a map() function in Python?

In Python, the map() function applies the given function to all the elements of a specified iterable, such as a list or tuple.

Syntax is:

map(func, itr)

In this syntax, func is a function applied to all the elements of an iterable, and itr is an iterable that has to be mapped. As a result of the execution, an object list will be returned.

Example:

# Define a lambda function for addition

addition = lambda n: n + n

# Create a list of numbers

numbers = [10, 20, 30, 40]

# Use the map function to apply the addition function to each element

result = list(map(addition, numbers))

# Print the result

print(result)

Output: 

20, 40, 60, 80

It performs the same addition operation on each element in the list and produces the list of doubled values as the output.

  1. Write a C++ program coding to generate a Fibonacci series.

The Fibonacci series is a numerical sequence where each number results from adding the two preceding numbers. The initial two numbers in the Fibonacci series are always 0 and 1. The

The Fibonacci series is defined as follows:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55….

The provided program is designed to generate and display the Fibonacci series based on a user-defined range of ‘n’ numbers. If the user enters a range value of 1, only the initial ‘num1’ value (0) will be printed. For a range value of 2, both ‘num1’ and ‘num2’ values (0 and 1) will be printed. If the user specifies a range of ‘n,’ the program will print ‘num1’ and ‘num2’ values, and then each subsequent term in the series will be calculated by adding the two preceding numbers. This process continues until ‘n’ numbers are generated in the Fibonacci series.

Coding:

#include <iostream>

using namespace std;

int main() {

int num1 = 0, num2 = 1, nextnum, n, i;

cout << “Enter the value for range: “;

cin >> n;

cout << “Fibonacci series is:” << endl;

if (n == 1)

cout << num1 << endl;

else if (n == 2)

cout << num1 << “\t” << num2 << endl;

else {

cout << num1 << “\t” << num2 << “\t”;

for (i = 3; i <= n; i++) {

nextnum = num1 + num2;

cout << nextnum << “\t”;

num1 = num2;

num2 = nextnum;

}

}

return 0;

}

  1. Create a program to output the k largest elements from an array. The order of the array elements is arbitrary. For instance, if the array contains [1, 23, 17, 9, 32, 2, 50], and the task is to print the top three largest elements (k = 3), the expected result would be 50, 32, and 23.

Coding:

#include <iostream>

#include <vector>

#include <queue>

using namespace std;

void printKLargestElements(const vector<int>& arr, int k) {

priority_queue<int> maxHeap;

// Push the first ‘k’ elements into the max heap

for (int i = 0; i < k; i++) {

maxHeap.push(arr[i]);

}

// Process the rest of the elements in the array

for (int i = k; i < arr.size(); i++) {

if (arr[i] > maxHeap.top()) {

maxHeap.pop();

maxHeap.push(arr[i]);

}

}

// Print the k largest elements in descending order

cout << “The ” << k << ” largest elements are: “;

while (!maxHeap.empty()) {

cout << maxHeap.top() << ” “;

maxHeap.pop();

}

cout << endl;

}

int main() {

vector<int> arr = {1, 23, 17, 9, 32, 2, 50};

int k = 3;

printKLargestElements(arr, k);

return 0;

}

Output:

The 3 largest elements are: 50, 32, 23

In this program, we use a max heap to keep track of the k elements. We initially push the first k elements into the max heap and then iterate through the rest of the array, replacing elements in the max heap if we encounter larger ones. Finally, we print the k largest elements in descending order.

  1. Create a program in C++ that, given an array of integers, determines if a triplet (a, b, c) exists where a^2 + b^2 equals c^2 and returns true in that case.

Coding:

#include <iostream>

#include <vector>

#include <queue>

using namespace std;

void printKLargestElements(const vector<int>& arr, int k) {

priority_queue<int> maxHeap;

// Push the first ‘k’ elements into the max heap

for (int i = 0; i < k; i++) {

maxHeap.push(arr[i]);

}

// Process the rest of the elements in the array

for (int i = k; i < arr.size(); i++) {

if (arr[i] > maxHeap.top()) {

maxHeap.pop();

maxHeap.push(arr[i]);

}

}

// Print the k largest elements in descending order

cout << “The ” << k << ” largest elements are: “;

while (!maxHeap.empty()) {

cout << maxHeap.top() << ” “;

maxHeap.pop();

}

cout << endl;

}

int main() {

vector<int> arr = {1, 23, 17, 9, 32, 2, 50};

int k = 3;

printKLargestElements(arr, k);

return 0;

}

Output:

A triplet (a, b, c) satisfies a^2 + b^2 = c^2.

This program checks if a triplet in the array satisfies the condition a^2 + b^2 = c^2. It first calculates the squares of all elements and stores them in a set. Then, it iterates through pairs of elements in the array and checks if the sum of their squares is in the set. If found, it returns true or else it returns false.

  1. What is Virtual Inheritance?

The purpose of Virtual inheritance in C++ is to reduce uncertainty and restrict the generation of multiple instances of a parent class during the involvement of multiple inheritance. It is usually applied during a class inherited from more than one parent class, and specific classes among them will have a shared common ancestor. When no virtual inheritance occurs, these cases will result in a “diamond problem” or uncertainty within the inheritance hierarchy. Let’s break down the concept of virtual inheritance:

The Diamond Problem: Consider a scenario where you have a class A and two other classes, B and C, derived from A. Now, you create a class D derived from both B and C. This results in a diamond-shaped inheritance hierarchy:

A

/

BC

 \ /

 D

The diamond problem arises when a member function or a data member is accessed from class `D`. It becomes ambiguous which instance of `A` is meant to be used, the one inherited through `B` or the one inherited through `C`.

Solution with Virtual Inheritance: You can use virtual inheritance to resolve the diamond problem and ensure that only one instance of the shared base class `A` exists. To make a base class virtually inherited, you specify the `virtual` keyword before the base class in the derived class declaration:

Coding:

“`cpp

class A {

// …

};

class B: virtual public A {

// …

};

class C: virtual public A {

// …

};

class D : public B, public C {

// …

};

With virtual inheritance, only one instance of class A is shared by both B and C. This ensures there is no uncertainty when accessing members of A from class D.

How It Works: When you use virtual inheritance, the compiler ensures that the common base class (A in this case) is only constructed once and that the derived classes (B and C) share a single instance. This is achieved by adding additional information to the class layout (typically a virtual table pointer or vptr) to manage this shared base class. When an object of D is created, it will have a single instance of class A accessible through both B and C.

Use Cases: Virtual inheritance is typically used when you have complex multiple inheritance hierarchies and want to avoid uncertainty and prevent the creation of multiple instances of a common base class. It’s beneficial when working with frameworks or libraries where you don’t have control over the entire class hierarchy.

If you are looking for more job updates, explore Free Alert Jobs.

Differentiation-Based Accenture Interview Questions

  1. Distinguish between Array and ArrayList provided by Java.
Array Array List
It is of fixed length. It is of variable length.
An array’s length can’t be modified if once created. It is possible to modify the array list length after creating it.
Arrays can store both primitive types and objects. Array lists can only store objects. They convert primitive types into objects instead of storing them.
Elements can be stored in an array using an assignment operator. Elements are stored in an array list using an add() method.
It can be multi-dimensional. It can be one-dimensional.
  1. Compare and state the differences between C, C++, and Java.
C C++ Java
C is a procedural language. C++ is considered an object-oriented programming language, although it’s not exclusively object-oriented. This allows the possibility of writing code that doesn’t involve creating classes. Java is classified as an OOP language, yet it is not entirely object-oriented due to its support for primitive data types.
C support pointers. C++ supports pointers. Java lacks support for pointers.
It is a platform-dependent language. C++ is a platform-dependent language. Java is a platform-independent language.
It is not possible to generate our package in C. In C++, it is possible to create the package. In Java, we can generate our package and can include the classes.
The concept of inheritance still needs to be implemented in C. In C++, we can use multiple inheritance. Java lacks support for multiple inheritance.
C lacks support in data hiding. So, data in C is less secure and can be accessed by the outside world. Secured and can be accessed by the outside world. C++ supports data hiding, so accessing data from the outside world is impossible. Java supports data hiding, so data cannot be accessed from the outside world.
  1. Differentiate between the Primary key and the Unique key in SQL.
Primary key Unique key
The primary key is a distinct identifier for every row within a table. A unique key is a unique identifier for table rows without a Primary key.
A table can only hold a single primary key. A table can have multiple unique keys.
In a table, neither NULL values nor duplicate values are allowed. It can accommodate a single NULL value, but duplicate values are not allowed.
When defining a Primary key, a clustered index is automatically generated if it is not already in the table. In order to enforce the UNIQUE constraint, a non-clustered index is built by default when a unique key is established.
  1. Differentiate between Dictionary and Tuple in the contact of Python.
Dictionary Tuple
It is a collection of unordered data where data will be stored in the key-value pairs form. A tuple is a collection of ordered data.
In the Dictionary, the elements are accessible using fundamental values. In the Tuple, the elements are accessible using numeric index values.
A dictionary can accommodate an arbitrary number of values. A tuple is restricted to a predetermined number of values.
The dictionary is used as a model object. A tuple is used for returning multiple values from a function.
  1. Differentiate between a Constructor and a Destructor.
Constructor Destructor
A constructor is a particular member function used to initialize an object when it is created. It sets up the initial state and allocates any required resources for the object. Constructors are typically responsible for initializing member variables and performing necessary setup operations. A destructor is a specific member function employed to manage resource cleanup and release when an object falls out of scope or is explicitly deleted. It is responsible for releasing any resources the object allocates during its lifetime, such as memory, file handles, or network connections.
In C++, a constructor has the same name as the class and does not have a return type. It is called automatically when an object is created.

Syntax:

class MyClass {

public:

MyClass() {

// Constructor code

}

};A destructor also has the same name as the class but is preceded by a tilde (~). It does not have parameters or a return type and is called automatically when an object goes out of scope.

Syntax:

class MyClass {

public:

~MyClass() {

// Destructor code

}

};A class can have multiple constructors with different parameter lists (overloading). Constructors are used to generate and initialize objects.A class has only one destructor. Destructors clean up and release resources when objects are no longer needed.Derived classes do not inherit constructors, but they can be called explicitly in the initialization list of the derived class’s constructor.Derived classes do not inherit destructors, but the base class’s destructor is called automatically when the derived class’s destructor is executed.When an object is formed, its constructors are automatically called. It’s not necessary to phone them directly.When an object exits its scope, its destructor is automatically called. Alternatively, you can use the delete operator to call the destructor directly.

  1. Differentiate between a checked and an unchecked exception.
Checked Exception Unchecked Exception
The compiler detects checked exceptions during the compilation process and enforces that code handling these exceptions must be in place before the program can be compiled successfully. Code that throws unchecked exceptions is not required to handle or declare them explicitly. Unchecked exceptions can be caught and handled, but it’s not mandatory. Handling them is often optional because they are usually related to programming errors that should be fixed during development.
Code that raises or propagates checked exceptions is required to either handle the exception using a try-catch block or indicate that it may throw the exception using the throws clause. This process enforces error handling. Code that throws unchecked exceptions is not required to handle or declare them explicitly. Unchecked exceptions can be caught and handled, but it’s not mandatory. Handling them is often optional because they are usually related to programming errors that should be fixed during development.
Example: 

In Java, common checked exceptions include IOException, FileNotFoundException, and SQLException. These exceptions typically involve external factors like file I/O or database operations, and the programmer must account for the potential errors.Example: 

Common unchecked exceptions include NullPointerException, ArrayIndexOutOfBoundsException, and ArithmeticException. These exceptions often relate to logical errors, such as accessing a null reference or dividing by zero.

In conclusion, Accenture is a management, outsourcing, technology & IT services company. Accenture involves diverse business sectors, like CRM, business strategies, supply chain management, outsourcing, and technologies. It is equally important to master behavioural and situational questions and showcase your problem-solving abilities, adaptability, and teamwork skills. We will delve into frequently asked Accenture Interview Questions in this blog.

Leave a Reply

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