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.

What is the Golden Ratio?

Answer»

Any two CONSECUTIVE (one after the other) Fibonacci Numbers have a ratio that is very close to the Golden Ratio, which is equal to 1.618034.... (approx). In fact, the larger the pair of Fibonacci Numbers, the closer the approximation. LET's have a look at a few:

3/2 = 1.55/3 = 1.666666666......233/377 = 1.618055556...

This also works when we start the sequence with two RANDOM WHOLE numbers.

Useful Preparation Resources:

Java 

Automation Testing

API Testing

SQL

2.

What do you know about anonymous FTP (File Transfer Protocol)?

Answer»

Users can access public DATA through anonymous FTP. The server does not need the user to identify himself, and the login is anonymous. As a RESULT, while utilizing anonymous FTP, you must substitute 'anonymous' for the user id. Anonymous FTPs allow you to send large FILES to a large number of individuals WITHOUT having to give out a large number of password and username combinations.

3.

How does the dynamic host configuration protocol help with network management?

Answer»

The network administrator USES the dynamic host configuration protocol to create a pool of IP addresses INSTEAD of going to each client computer to configure a STATIC IP address. This group is known as an AREA that can be dynamically ASSIGNED to clients.

4.

What is a DNS (Domain Name System) forwarder?

Answer»

A DNS forwarder is a DNS server that FORWARDS DNS queries for external DNS names to DNS servers outside the network. A forwarder is used with a DNS server when it receives DNS queries that cannot be resolved quickly. Therefore, it forwards these requests to external DNS servers for resolution. 

A DNS server that is configured as a forwarder behaves differently than a DNS server that is not configured as a forwarder. 

The DNS server behaves as FOLLOWS when configured as a forwarder: 

  • When the query is RECEIVED by the DNS server, it resolves it using a cache.
  • If the DNS server is not able to resolve the request, it forwards it to another DNS server.
  • If the forwarder is not AVAILABLE, it tries to resolve the query using a root hint.
5.

What are virtual functions and pure virtual functions?

Answer»

A virtual function is a member function that is declared in a BASE class and overridden by a derived class. When we are using a pointer or a reference to the base class to refer to a derived class object, we can invoke a virtual function for that object and have it run the derived class's version of the function.

  • Regardless of the type of reference (or pointer) used for a function call, virtual functions make SURE the RIGHT function is called for an object.
  • They're MOSTLY implemented to accomplish POLYMORPHISM at runtime.
  • The virtual keyword is used to declare functions in base classes.
  • Run-time resolution of function calls is performed.

Functions that are only declared in the base class are known as pure virtual functions or abstract functions. This indicates that they have no definition in the base class and must be redefined in the subclass.

6.

What is the difference between new() and malloc()?

Answer»

In C++, both malloc() and new are used for memory ALLOCATION at runtime. The differences are listed below:

  • Malloc() is a function, whereas new() is a pre-processor.
  • When using new(), there is no requirement to allocate memory; nevertheless, when using malloc(), you must use sizeof ().
  • new() SETS the new memory to 0 and malloc() assigns a RANDOM value to the newly allocated memory.
  • The new() OPERATOR ALLOCATES memory and invokes the constructor for object initialization, whereas the malloc() function allocates memory but does not invoke the constructor.
  • Because the operator is faster than the function, the new() operator is faster than the malloc() function.
7.

What distinguishes a structure from a class in C++?

Answer»

There are a few distinctions between a class in C++ and a structure. 

These are the following:

  • When creating a structure from a class or another structure, the base class or structure's default access specifier is PUBLIC. When deriving a class, on the other hand, the default access specifier is private.
  • The members of a structure are always public, but the members of a class are always private.
  • The variables of a structure are STORED in the STACK memory while those of the class are stored in the heap memory.
  • Class supports inheritance whereas structures do not.
  • The TYPE of class is reference type whereas the type of structure is a VALUE type.
8.

List the advantages of using Tries over Binary Search Trees (BSTs).

Answer»

The advantages of Tries over binary search trees (BSTs) are as follows:

  • It's quicker to lookup keys. In the WORST-case scenario, looking up a key of length m takes O(m) time. Because lockups are DEPENDENT on the depth of the tree, which is logarithmic in the NUMBER of keys if the tree is balanced, a BST does O(log N) key comparisons, where n is the number of items in the tree. As a result, a BST takes O(m log n) time in the worst scenario. Furthermore, log(n) will approach m in the worst-case scenario. Also, on real PROCESSORS, the simple actions Tries utilize during lookup, such as array indexing with a character, are quick.
  • Because nodes are shared between keys with common starting sub-sequences, tries with a large number of short keys are more space-efficient.
  • Tries facilitate longest-prefix matching, assisting in the discovery of the key with the longest possible prefix of characters, all of which are unique.
  • The length of the key is equal to the number of internal nodes from root to leaf. As a result, balancing the tree isn't an issue.
9.

Is there a good reason to choose BSTs over AVLs in the first place?

Answer»

If you wish to compare the two: an AVL tree to a simple binary search tree (BST) without balancing it, then AVL:

  • will require ADDITIONAL memory (each node must keep TRACK of its balance factor) and
  • Each operation has the potential to be slower (because you need to maintain the balance factor and sometimes perform rotations).

The worst-case for BST without balancing is quite terrible (linear). However, if you are confident that this worst-case scenario will not OCCUR, or if you don't mind if the process is slow in rare CIRCUMSTANCES, BST without balancing may be preferable to AVL.

10.

What are the disadvantages of using an array to implement Queue?

Answer»

The cons of using an array to implement a queue are:

  • Even if the queue is empty, if it has a significant number of ENQUEUE and dequeue OPERATIONS, we may not be able to INSERT entries at some time (as in the case of linear increment of front and rear indices) (this PROBLEM is solved by using circular queue).
  • When using an array to construct a queue, there may be occasions where we need to extend the queue to insert additional elements. Because it is nearly impossible to extend the array size when using an array to implement a queue, determining the suitable array size is ALWAYS an issue.
11.

What are the advantages of NumPy arrays over Python lists?

Answer»

The following are some advantages of NumPy arrays over PYTHON lists:

  • NumPy arrays store data in a sequential manner, unlike Python lists, making data processing simpler.
  • NumPy is not just more efficient, but it's also easier to use. We get a lot of vector and matrix operations for free, allowing US to avoid doing unnecessary WORK. They're also put to good use.
  • NumPy arrays are faster, and NumPy has a lot of useful FEATURES like FFTs, convolutions, quick searching, simple statistics, LINEAR algebra, histograms, and so forth.
12.

Distinguish between range and xrange in Python.

Answer»

xrange and range are nearly identical in terms of functionality. They both allow you to generate a list of integers that you may use whatever you WANT. The only difference between range and xrange is that xrange produces an xrange object while range provides a Python list object.

This implies that, unlike range, xrange does not create a STATIC list during EXECUTION. It generates the values as needed using a technique known as yielding. Generators, which are a type of object, are employed with this technique. That is, if you have a large range and want to construct a list for a billion people, you should use xrange.

This is particularly the case if you're working with a system that demands a lot of memory, such as a cell phone, because range will utilise as MUCH RAM as it can to build your array of numbers, causing a memory problem and crashing your app.

13.

How is memory managed in Python?

Answer»

PYTHON's private heap space is in charge of memory management. The private heap contains all Python objects and data structures, but the programmer does not have access to it. The Python interpreter, on the other hand, takes care of this.

  • The memory manager in Python is in charge of ALLOCATING heap space for Python objects. The core API then GIVES the programmer access to a few programming tools.
  • It also contains an integrated garbage collector, which, as the NAME implies, recycles all unused memory and makes it available to the heap space.
14.

Explain shallow copy vs deep copy in the context of Java.

Answer»

The method of copying an object that is used by default in cloning is a shallow copy. The fields of an old object X are copied to a new object Y in this procedure. The reference is duplicated to Y while copying the object type field, i.e. object Y will point to the same location as X. If the field value is a primitive type, the primitive type's value is copied. As a result, any changes made in object X or Y's linked objects will be REFLECTED in other objects.

// Java// An object reference of this class is// contained by IBSclass IB { int a, b;} // Contains a reference of IB and// implements clone with shallow copy.class IBS implements Cloneable { int x; int y; IB z = new IB(); public Object clone() throws CloneNotSupportedException { return super.clone(); }}// Driver classpublic class Main { public static void main(String ARGS[]) throws CloneNotSupportedException { IBS t1 = new IBS(); t1.x = 1; t1.y = 2; t1.z.a = 3; t1.z.b = 4; IBS t2 = (IBS)t1.clone(); // a copy of object t1 is CREATED // and is PASSED to t2 t2.x = 10; // any modification in the primitive type of t2 // does not get reflected in the t1 field t2.z.a = 30; // any modification in object type field // gets reflected in both t2 and t1(shallow copy) System.out.println(t1.x + " " + t1.y + " " + t1.z.a + " " + t1.z.b); System.out.println(t2.x + " " + t2.y + " " + t2.z.a + " " + t2.z.b); }}

Output:

1 2 30 410 2 30 4

In the above PROGRAM, t1.clone returns a shallow copy of the object t1. After receiving the copy, specific modifications to the clone technique must be applied in order to acquire a deep copy of the object.

A deep copy duplicates all fields as well as the dynamically allocated memory that the fields point to. When an item is copied together with the objects to which it refers, it is called a deep copy.

// Java// An object reference of this// class is contained by IBSclass IB { int a, b;} // Contains a reference of IB and// implements clone with deep copy.class IBS implements Cloneable { int x, y; IB z = new IB(); public Object clone() throws CloneNotSupportedException { // Assigning the shallow copy to // the new reference variable t IBS t = (IBS)super.clone(); // Creating a deep copy for c t.z = new IB(); t.z.a = z.a; t.z.b = z.b; // Creating a new object for the field c // and assigning it to the obtained shallow copy // in order to make it a deep copy return t; }}public class Main { public static void main(String args[]) throws CloneNotSupportedException { IBS t1 = new IBS(); t1.x = 1; t1.y = 2; t1.z.a = 3; t1.z.b = 4; IBS t3 = (IBS)t1.clone(); t3.x = 10; // any modification in the primitive type of t2 // does not get reflected in the t1 field t3.z.a = 30; // any modification in object type field of t2 // does not get reflected in t1(deep copy) System.out.println(t1.x + " " + t1.y + " " + t1.z.a + " " + t1.z.b); System.out.println(t3.x + " " + t3.y + " " + t3.z.a + " " + t3.z.b); }}

Output:

1 2 3 410 2 30 4

We can see how a new object for the IB class has been designated to replicate an object that will be delivered to the clone method in the preceding example. As a result, t3 will acquire a deep copy of t1's object. As a result, any changes made by t3 to the ‘z' object properties will not be reflected in t1.

15.

Why are Java Strings immutable in nature?

Answer»

String OBJECTS in Java are immutable by definition. This signifies that the String object's state cannot be changed once it has been created. As a result, if you try to UPDATE the value of that object rather than the values of that object, Java creates a new string object.

Because String objects are often cached in the String pool, Java String objects are immutable. Because String literals are frequently shared among numerous clients, one client's action may have an impact on the others. It improves the application's SECURITY, caching, synchronization, and performance by doing so.

To begin, we've developed a string literal “Python” that runs in the pool. The string “Data Science” is then formed, and it is also used in the pool. Finally, we've constructed the “Python” string once more. However, JVM checks for the string at this point and finds that the string literal is indeed present. INSTEAD of creating a new String pool instance, it returns the pooled instance's reference, i.e. str1.

Similarly, if we use the new keyword to produce string literals, we're using the String pool. Three string literals have been created: “Java”, “C++”, and “Data Science”. We can see that string literals in “Java” and “C++” are new. However, there is already a “Data Science” literal in the pool. JVM now allocates SPACE in the Java heap for the literal “Data Science”. It's important to remember that all String literals formed with the new keyword are stored in the Java heap, not the String pool.

16.

What is Java String Pool?

Answer»

The developers of Java were WELL aware that programmers would rely heavily on the String data type. As a result, they sought optimization from the BEGINNING. They came up with the idea of storing String literals in the String pool (storage space in the Java heap).

As a result, whenever a new object is created, the String pool first checks to see if the object has previously been generated in the pool, and if it has, the same reference is RETURNED to the variable. Otherwise, a new object in the String pool will be created and the reference will be returned.

They wanted to use SHARING to reduce the size of the TEMPORARY String object. To make sharing easier, an immutable class is required. It is not possible to share mutable structures with two unknown parties. As a result, immutable Java Strings aid in the implementation of the String Pool concept.

17.

Illustrate public static void main(String args[]) in Java.

Answer»

The entry POINT for any Java code is called main() and is always written as a public static VOID main (String[] ARGS).

  • public: The term "public" REFERS to an access modifier. It's used to specify who has access to use this method. This method is public, which implies that it can be accessed by any class.
  • static: This is a keyword that indicates that it is a class-based system. In Java, main() is made static so that it can be accessed without having to create a class instance; however if main is not made static, the compiler will throw an error because main() is called by the JVM before any objects are created, and only static methods can be directly invoked via the class.
  • void: The return type of a method is void, and it defines a method that does not return any value.
  • main: It's the name of the method that JVM looks for when it's searching for a starting point for an application with a specific signature, and it's the method where the main execution happens.
  • String args[]: The parameter passed to the main method is String args[]. args[] is an array of arguments with each ELEMENT as a string.
18.

What is the drawback of scanf() and how can it be avoided (if any)?

Answer»

With a STRING of characters, scanf() will fail. A multi-word string cannot be entered into a single variable using scanf(). The GETS( ) function is USED to avoid this. When the enter key is pushed, it gets a string from the keyboard and ends it. As part of the input string, SPACES and tabs are PERMITTED.

19.

To connect the C program and the operating system, what structure is used?

Answer»

The FILE structure is used to connect the operating system and an APPLICATION. The header file “stdio.h” (standard input/output header file) defines the file. It contains information on the currently open file, its current size, and its MEMORY LOCATION. It has a CHARACTER pointer that indicates which character is currently being opened. When you open a file, you're telling the software and the operating system which file you want to open.

20.

What do you know about #pragma directive?

Answer»

#pragma is a preprocessor directive for turning on or off specific FUNCTIONALITIES. #pragma startup, #pragma EXIT, and #pragma WARN are its three types.

  • We can use #pragma startup to provide functions that are called when the script starts working.
  • #pragma exit ALLOWS US to specify functions that are executed when the code terminates.
  • #pragma warn tells the computer whether or not to suppress any warnings.
21.

What is the difference between getch() and getche()?

Answer»

Both these C FUNCTIONS read CHARACTERS from the keyboard, the only DIFFERENCE being:

  • GETCH() is a function that reads characters from the keyboard without using any buffers. As a result, no data is presented on the screen.
  • getche() uses a buffer to read characters from the keyboard. As a result, information is displayed on the screen.

Here is an example to demonstrate the difference between the two functions:

#include&LT;stdio.h>#include<conio.h>int main(){ char c; printf("Enter a character here: "); c = getch(); printf("nYou entered the character: %c",c); printf("nEnter another character: "); c = getche(); printf("nYour new entered character is: %c",c); return 0;}

Output:

Enter a character here:You entered the character: cEnter another character: bYour new entered character is: b

getch() immediately returns the character without waiting for the enter key to be pressed and the character is not displayed on the screen. getche() displays the character on the screen without waiting for the enter key to be pressed.

22.

What is the difference between Dataset.clone() and Dataset.copy()?

Answer»

DataSet. Clone() copies only the DataSet object's SCHEMA and RETURNS a DataSet object with the same structure as the existing dataset object, including all the relations, constraints, and SCHEMAS. The data from the OLD one will not be copied to the NEW one.

DataSet.Copy() copies the entire code and structure of an existing DataSet object. 

23.

Distinguish between UNION and UNION ALL.

Answer»

To aggregate the results of TWO or more SQL SELECT QUERIES, we USE the SQL UNION method. In the union operation, the number of data types and columns in both tables on which the UNION action is performed must be the same. Duplicate rows are REMOVED from the result set by the UNION operation. Union ALL operation is the same as a Union operation. It returns the set without sorting the data or DELETING duplicates.

24.

Why is normalization needed in a database?

Answer»

The term "normalization" refers to the process of analyzing relation schemas BASED on their functional dependencies. Normalization is the TECHNIQUE of splitting up data into numerous TABLES to reduce redundancy.

The advantages of normalization are:

  • Standardization eliminates the copy information, allowing a smaller database to be maintained. As a result, the size of the database is reduced in general.
  • Better execution is assured, which is related to the previous point. As the size of information bases shrinks, the time it takes to process it becomes shorter and more CONSTRAINED, enhancing reaction time and speed.
  • Narrower tables may be possible as standardized tables are altered and feature fewer segments, allowing for more data items per page.
  • With fewer files per table, support assignments are completed faster (file modifies).
25.

Why is it suggested to utilise a database management system (DBMS)? List some of its primary advantages to explain.

Answer»

Following are some advantages of using DBMS:

  • Minimizing Data REDUNDANCY: DBMS SUPPORTS a system to eliminate data redundancy within the database by integrating all data into a single database, and because data is stored in only one location, there is no duplication of data.
  • Data Sharing: In a DBMS, data can be shared among several users at the same time because the same database is shared across all users and by various applications.
  • Data Integrity: This REFERS to the database's data being consistent and accurate at all times. It is CRITICAL because a database MANAGEMENT system (DBMS) contains numerous databases, each of which contains data that is visible to multiple users. As a result, it's critical to guarantee that data is accurate and consistent across all databases and for all users.
  • Data Security: Only approved users should be allowed access to the database, and their identities should be authenticated using a legitimate login and password. Under no circumstances should unauthorized users be allowed to access the database, as this would break the integrity limitations.