0% found this document useful (0 votes)
8 views

Copy of Accenture Tech Questions

Uploaded by

Rezin Info
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Copy of Accenture Tech Questions

Uploaded by

Rezin Info
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Tech-Interview

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

1 What purpose does the "static" keyword serve in Java? 3

2 Is it possible to implement multiple interfaces within a single Java class? 3

3 How do the "super" and "this" keywords hold significance in Java? 4

4 Define run-time polymorphism and elucidate how it is accomplished in Java. 4

5 Differentiate between the Array and ArrayList offered by Java. 5

6 Explain the concept of the "Diamond problem" in Java. 6

7 What criteria can be used to distinguish between C, C++, and Java? 6

8 Provide an overview of lambda expressions in Java. 7

9 How do you distinguish between "var++" and "++var" in Java? 8

10 Describe the memory allocation process in C. 8

Elaborate on the getch() function in a C++ program and highlight its differences from the getche()
11 9
function.

12 Define the term "Friend function" in C++. 9

13 Explain the concept of normalization in the context of databases. 9

14 Enumerate the differences between a Primary Key and a Unique Key in SQL. 10

15 What is the role of Pandas in the Python programming language? 10

16 Provide a definition of a classifier in Python. 10

17 What sets apart a dictionary from a tuple in Python? 11

18 Explain the purpose of the map() function in Python. 11

19 Define XML and its use in computer programming. 11

20 Write a C++ program to generate the Fibonacci series. 12

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.

2. Is it possible to implement multiple interfaces within a single Java class?

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:

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.

4. Define run-time polymorphism and elucidate how it is accomplished in Java.

• 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.

4
@freeway_monk
Output:

5. Differentiate between the Array and ArrayList offered by 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.

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”..

7. What criteria can be used to distinguish between C, C++, and Java?

6
@freeway_monk
8. Provide an overview of lambda expressions in Java.

• 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:

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:

10. Describe the memory allocation process in C.

• 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()

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.

12. Define the term "Friend function" in C++.

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.

13. Explain the concept of normalization in the context of databases.

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.
Example:
• First Normal Form(1NF)
• Second Normal Form(2NF)

9
@freeway_monk
14. Enumerate the differences between a Primary Key and a Unique Key in SQL.

15. What is the role of Pandas in the Python programming language?

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.

Some of the attributes or methods provided by Pandas are:


• axes: It returns a row axis label list.
• empty: It returns true if the series is empty otherwise it returns false.
• size: It returns the count of elements in the underlying data.
• values: It returns the series as ndarray.
• head(): It returns the n rows from the beginning of a data frame or series.
• tail(): Returns the n rows from the end of a data frame or series.

16. Provide a definition of a classifier in Python.

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?

18. Explain the purpose of the map() function 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:

Output: 20, 40, 60, 80

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

19. Define XML and its use in computer programming.

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.

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 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.

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.

You might also like