Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Write a C++ program for generating the Fibonacci series.

Answer»

The Fibonacci series is a number sequence in which each number is the sum of the previous two numbers. Fibonacci series will have 0 followed by 1 as its first two numbers.

The Fibonacci series is as follows:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55....

The below-given program will display the Fibonacci series of n range of numbers given by the user. If the entered range value is 1, the num1 value will be printed, i.e., 0. If the entered range value is 2, num1 and num2 values will be printed, i.e., 0 and 1. If entered range value is n, num1 and num2 value will be printed. Along with that, each next term will be calculated based on the addition of the previous two numbers and this process continues until it generates n numbers in a Fibonacci series.

#include<iostream.h>#include<conio.h>void main(){ int num1,num2,nextnum,n,i; cout<<"Enter the value for range:"; //Fibonacci series range value will be inputted cin>>n; num1=0; num2=1; cout<<"Fibonacci series is:"<<endl; if(n==1) cout<<num1<<endl; //Single value will be printed if range value is 1 else if(n==2) cout<<num1<<"\t"<<num2<<endl; //Two values will be printed if the range value is two else { cout<<num1<<"\t"<<num2<<"\t"; for(i=3;i<=n;i++) //Fibonacci series will be printed based on range limit { nextnum=num1+num2; cout<<nextnum<<"\t"; num1=num2; num2=nextnum; } } getch();}Conclusion

Accenture is among the leading Fortune 500 companies across the globe with revenue and profits better than most of the MNCs. It is also well-known for its diverse and robust work culture. Obtaining a career at Accenture would help you to upgrade your career growth and knowledge base.

Accenture recruits many candidates EVERY year for their several job opportunities. The candidates should put all their efforts to achieve their goals and the organization should pace up the process to gain more fame in the long run. Recently, Accenture has also ANNOUNCED that it is going to hire PLENTY of candidates across various roles, and hence this is an opportunity to give it your best shot.

Hope this article ASSISTS you to get more information about the Accenture interview process and help you ace through it. We have focused to cover the various aspects like Accenture company profile, Accenture interview questions for freshers/experienced, Accenture HR interview questions, Accenture technical interview questions, here in this article. Now brace yourself for every question thoroughly as this article is going to upgrade your understanding of the Accenture recruitment process.

Useful Resources:

SQL Interview

Java Interview

C++ Interview

Python Interview

2.

What is XML?

Answer»

XML(Extensible Markup Language) is a mark-up language that states rules for document encoding formatting in such a WAY that it can be easily understood by both humans and machines. It is USEFUL to describe the data, develop information formats, and SHARE structured data through the internet.

3.

What is a map() function in Python?

Answer»
  • In Python, the map() function is useful for applying the given function on every element of a specified iterable(list, tuple, etc.).
  • SYNTAX for map() function is: map(func, itr)
    Where func is a function applied to every element of an iterable and itr is iterable which is to be mapped. An object list will be RETURNED as a result of map() function execution.
  • Example:
def addition(n): return n+nnumber=(10, 20, 30, 40)res= map(addition, number)print(list(res))

Output: 20, 40, 60, 80

In the above code segment, we are passing the addition() function and number as parameters to the map() function. Now, the addition() function will be applied to every element of the number tuple, each ITEM value is ADDED with the same item value and the result generated will be stored in the res list.

4.

What is the difference between dictionary and tuple in Python?

Answer»
DictionaryTuple
A dictionary is an unordered DATA collection in which data will be STORED in the FORM of key-value pairs.A tuple is an ordered data collection.
Elements are accessed using key values.Elements are accessed using numeric index values.
Dictionary can have any number of values.A tuple can have only a pre-defined number of values.
It is USED as a MODEL object.It is useful for returning multiple values from a function.
5.

What is a classifier in Python?

Answer»

A classifier is an algorithm that PREDICTS the class of an input element on the basis of a set of features. Usually, it will make use of training data(large datasets used to train an algorithm or machine learning model) to obtain understand-ability regarding the relation between input variables and class. It is mainly used in machine learning and supervised learning.

Example: A classifier can be used to predict the soap category depending on its characteristics, which MEANS its “features”. These features may include its fragrance, appearance, color, ETC. A machine learning classifier COULD potentially be used to predict that soap with a round shape and brown color along with a strong fragrance of sandalwood is a Mysore SANDAL soap.

6.

Can you give differences for the Primary key and Unique key in SQL?

Answer»
PRIMARY keyUNIQUE Key
It is a unique identifier for each row of a table.It is a unique identifier for table ROWS in the absence of a Primary key.
A single Primary key is ALLOWED in a table.More than one Unique Key is allowed in a table.
NULL VALUE or duplicate value is not permitted.It can have a single NULL value but a duplicate value is not permitted.
When we define a Primary key, a clustered index is automatically created if it does not already exist on the table.When we define a Unique key, a non-clustered index is created by default to enforce a UNIQUE constraint.
7.

What is normalization in the database?

Answer»
  • Normalization(data normalization or DATABASE normalization) is the technique of data organization in the database to minimize data redundancy and improve data integrity. Through database normalization, we can organize the data in TABLES and columns, and also we can define a RELATIONSHIP between these tables or columns.
  • Below are the commonly USED 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)
8.

What is meant by the Friend function in C++?

Answer»
  • A friend() FUNCTION is a function that has access to private and PROTECTED members of another CLASS i.e., a class in which it is declared as a friend. It is POSSIBLE to declare a function as a friend function with the help of the friend keyword.
  • Syntax:
class class_name { //STATEMENTS friend return_type function_name();}
9.

Explain about getch() function in a C++ program. How it is different from getche() function?

Answer»

The GETCH() is a pre-defined LIBRARY function in C++ that is used to receive a single input character from the keyboard, and it holds the SCREEN until it does not receive any character from standard input. This function does not require any arguments and it is defined under the “conio.h” header file.

#INCLUDE<iostream.h> #include<conio.h>void main() { cout<<"Enter the character:"<<endl; getch(); }

This program holds the output screen until you press any character on the keyboard.

The only difference between these TWO functions is getch() does not echo the character to the screen whereas getche() does.

10.

Explain memory allocation process in C.

Answer»
  • Memory allocation process indicates reserving some part of the memory space based on the requirement for the code execution.
  • There are two types of memory allocation done in C:
    1. Static memory allocation: The memory allocation during the beginning of the program is known as static memory allocation. In this TYPE of memory allocation allocated memory size remains fixed and it is not allowed to change the memory size during run-time. It will MAKE use of a stack for memory management.
    2. Dynamic memory allocation: The memory allocation during run-time is considered as dynamic memory allocation. We can mention the size at runtime as per requirement. It will make use of heap data structure for memory management. The REQUIRED memory space can be allocated and DEALLOCATED from heap memory. It is mainly used in pointers. Four types of the pre-defined FUNCTION that are used to dynamically allocate the memory are given below:
      • malloc()
      • calloc()
      • realloc()
      • free()
11.

Can you differentiate between “var++” and “++var”?

Answer»

EXPRESSIONS “var++” and “++var” are used for incrementing the value of the “var” variable.

“var++” will first give the evaluation of expression and then its value will be INCREMENTED by 1, thus it is CALLED as post-incrementation of a variable. “++var” will increment the value of the variable by one and then the evaluation of the expression will take place, thus it is called pre-incrementation of a variable.
Example:

/* C program to demonstrate the difference between var++ and ++var */ #INCLUDE<stdio.h> int main() { int x,y; x=7, y=1; printf("%d %d\n", x++, x); //will generate 7, 8 as output printf("%d %d", ++y, y); //will generate 2, 2 as output }
12.

What are lambda expressions in Java?

Answer»
  • A Lambda expression is a function that can be created without including it in any class. It was introduced in Java 8.
  • It is used to provide the interface implementation which has a functional interface. It does not require defining the method again for providing the implementation, it is allowed to just write the implementation code. Thus it saves plenty of coding.
  • Lambda expression is considered as a function, the .class file will not be created by the compiler.
  • They are generally used for simple callbacks or event listeners implementation, or in functional programming with the Java Streams API.
  • Lambda Expression Syntax is:
    (argument_list) -> {body}
    THREE components of Lamda expression are:
    1. argument_list: Zero or more number of arguments.
    2. -> (arrow-token): Used to link argument_list and body of lambda expression.
    3. body: CONTAINS statements and expressions for lambda expression.
  • A Java example program to ILLUSTRATE lambda expressions by implementing the user-defined functional interface is given below:
// A functional interface with a single abstract method. interface ExampleInterface{ // An abstract method void abstractPrint(int a);}class InterviewBit{ public static void main(String args[]) { /* A lambda expression to implement the above functional interface. */ ExampleInterface OB = (int a)->{System.out.println(a)}; // This calls above lambda expression and prints 20. ob.abstractPrint(20); }}

In the above example program, Example Interface is the functional interface that has a single abstract method abstractPrint(). By using lambda expression within InterviewBit class, we are implementing the functional interface by providing implementation code for the abstract method within an interface.

13.

How can you differentiate between C, C++, and Java?

Answer»
C++Java
It is a procedural LANGUAGE.It is an object-oriented language (not purely object-oriented as it is POSSIBLE to write code without the creation of a class).It is an object-oriented language (not purely object-oriented, as it supports primitive data types).
It supports pointers.It supports pointers.It does not support pointers.
Platform dependent languagePlatform dependent languagePlatform INDEPENDENT language
Not possible to create our own package.It is allowed to create the package in C++.Here, we can create our package and can include the classes.
The concept of inheritance was not implemented.We can use MULTIPLE inheritances in C++.It does not support multiple inheritances.
It does not support data hiding, so data is less secured as it can be accessed by the OUTSIDE world.It supports data hiding, so data cannot be accessed by the outside world.It supports data hiding, so data cannot be accessed by the outside world.
14.

What is the “Diamond problem” in Java?

Answer»

The “DIAMOND problem” usually happens in multiple inheritances. Java does not support multiple inheritances, so in the case of Java, the diamond problem occurs when you are trying to implement multiple interfaces. When two interfaces having METHODS with the same signature are implemented to a single class, it creates ambiguity for the compiler about which function it has to CALL, so it produces an error at the compile time. Its STRUCTURE looks similar to diamond thus it is called a “Diamond problem”. 

Here, if we try to access the print() function using the DerivedClass3 object, it will create confusion for the compiler that which copy of the print() function it has to call i.e., from DerivedClass1 or DervivedClass2.

“Diamond problem” is solved by using virtual inheritance. It guarantees that the child class will get only one instance of the common base class.

15.

Distinguish between Array and ArrayList provided by Java.

Answer»
ArrayArrayList
An array is of fixed lengthArrayList is of variable length
Length of the array cannot be changed once createdLength of the array can be changed after creation
It can STORE both primitive types and objectsIt can store only objects, not primitives(it automatically converts primitive TYPE to object)
USING an assignment operator we can store ELEMENTS into an arrayWith the help of add() method elements are stored into an ArrayList
An array can be multi-dimensionalArrayList is always one-dimensional
16.

What is run-time polymorphism and how it is achieved in Java?

Answer»
  • Run-time polymorphism(dynamic binding or dynamic method dispatch) implies that the call to an overridden method is RESOLVED dynamically during run-time instead of compile-time.
  • Run-time polymorphism is achieved with the help of method overriding in Java. When a child class(subclass) has the same method name, return type, and parameters as the parent(superclass), then that method overrides the superclass method, this process is known as method overriding.
    Example:
    The below example has one superclass ANIMAL and three subclasses, Birds, Mammals, and Reptiles. Subclasses extend the superclass and override its PRINT() method. We will call the print() method with the help of the reference variable of Animal class i.e., parent class. The subclass method is invoked during runtime since it is referring to the object of the subclass and the subclass method overrides the superclass method. As Java Virtual Machine(JVM) decides method invocation, it is run-time polymorphism.
class Animal{ void print(){ System.out.println("Inside Animal"); } } class Birds extends Animal{ void print(){ System.out.println("Inside Birds"); } }class Mammals extends Animal{ void print(){System.out.println("Inside Mammals");} }class Reptiles extends Animal{ void print(){ System.out.println("Inside Reptiles"); } }class InterviewBit{ public STATIC void main(String args[]){ Animal a = new Animal(); Animal b = new Birds(); //upcasting Animal m = new Mammals(); //upcasting Animal R = new Reptiles(); //upcasting a.print(); b.print(); m.print(); r.print(); } }

Output:

Inside AnimalInside BirdsInside MammalsInside Reptiles
17.

What is the significance of the “super” and “this” keywords in Java?

Answer»
  • super keyword: In Java, the “super” keyword is used to provide reference to the INSTANCE of the PARENT CLASS(superclass). Since it is a reserved keyword in Java, it cannot be used as an identifier. This keyword can also be used to invoke parent class members like constructors and methods.
  • this Keyword: In Java, the “this” keyword is used to REFER to the instance of the current class. Since it is a reserved keyword in Java, it cannot be used as an identifier. It can be used for referring object of the current class, to invoke a constructor of the current class, to pass as an argument in the method call or constructor call, to RETURN the object of the current class.
18.

Can we implement multiple interfaces in a single Java class?

Answer»

Yes, it is allowed to implement multiple interfaces in a single class. In Java, multiple INHERITANCES is achieved by implementing multiple interfaces into the class. While implementing, each interface NAME is separated by using a comma(,) operator.
Syntax:

public class ClassName IMPLEMENTS Interface1, Interface2,..., InterfaceN{ //Code }

EXAMPLE:

public class InterviewBit implements X, Y{ //Code}

Here, X and Y are the interfaces implemented by the class InterviewBit.

19.

What is the use of “static” keyword in Java?

Answer»
  • The static KEYWORD is a non-access modifier in Java that is useful for memory management.
  • Static property can be shared by all the objects, no SEPARATE copies of static members will be created on object creation.
  • No need to create the instance of the class for accessing static members, we can directly access them by using the class name.
  • The static keyword can be used with the variable, block, method, and nested classes for memory management.
    • Static variable: When a variable is declared with the static keyword, a single copy of the variable will be created and the same variable will be shared across all objects of the class (a class to which the static variable belongs).
    • Static block: A static block helps with the initialization of the static data members. It is a group of statements WITHIN a Java class and gets executed exactly once when the class is first loaded into the JVM(Java Virtual MACHINE).
    • Static method: If the method is declared with the static keyword, then it is considered a static method. The main( ) method is one of the examples of a static method. Static methods are having restrictions such as they can directly call other static methods only, and they can access static data directly.
    • Static class: Only a nested class can be created as a static class. Nested static class doesn’t need a REFERENCE of Outer class(a class in which the nested class is defined). A static class does not have permission to access non-static members of the Outer class.