Copy of Accenture Tech Questions
Copy of Accenture Tech Questions
Questions
Disclaimer: The views, opinions, and information expressed in this E-book are solely those of the individual authors and do
not necessarily represent the views or opinions of Accenture. The content provided is for informational purposes only and
is not intended to be a substitute for professional advice.
1
@freeway_monk
S/No Questions Page No
Elaborate on the getch() function in a C++ program and highlight its differences from the getche()
11 9
function.
14 Enumerate the differences between a Primary Key and a Unique Key in SQL. 10
2
@freeway_monk
1. What purpose does the "static" keyword serve in Java?
• 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.
Example:
3
@freeway_monk
3. How do the "super" and "this" keywords hold significance in Java?
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.
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.
4
@freeway_monk
Output:
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.
5
@freeway_monk
6. Explain the concept of the "Diamond problem" in Java.
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”..
6
@freeway_monk
8. Provide an overview of lambda expressions in Java.
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.
7
@freeway_monk
9. How do you distinguish between "var++" and "++var" in Java?
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:
• 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.
8
@freeway_monk
11. Elaborate on the getch() function in a C++ program and highlight its differences from the
getche() function.
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.
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.
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.
9
@freeway_monk
14. Enumerate the differences between a Primary Key and a Unique Key in SQL.
Pandas is a Python library used for data manipulation and analysis. It provides a convenient
way to analyze and clean data, and introduces two new data structures to Python - Series
and DataFrame - both of which are built on top of NumPy. Pandas is a fast, powerful, flexible,
and easy-to-use library that allows for fast analysis and data preparation and cleaning.
Anyone can view its source code and make suggestions using pull requests.
A classifier is an algorithm that predicts the class of an input element on the basis of a set of
features. It is mainly used in machine learning and supervised learning. The main goal of the
Classification algorithm is to identify the category of a given dataset, and these algorithms
are mainly used to predict the output for the categorical data.
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
10
@freeway_monk
17. What sets apart a dictionary from a tuple in Python?
• 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:
In the above code segment, we are passing the addition() function and number
as paraevery 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.
meters to the map() function. Now, the addition() function will be applied to
11
@freeway_monk
20. Write a C++ program to generate the Fibonacci series.
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 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.
12
@freeway_monk
@freeway_monk
Disclaimer: The views, opinions, and information expressed in this E-book are solely those of the individual authors and do
not necessarily represent the views or opinions of Accenture. The content provided is for informational purposes only and
is not intended to be a substitute for professional advice.