InterviewSolution
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: |
|
| 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.
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:
|
|
| 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:
|
|
| 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:
|
|
| 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:
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:
|
|
| 11. |
What are the advantages of NumPy arrays over Python lists? |
|
Answer» The following are some advantages of NumPy arrays over PYTHON lists:
|
|
| 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.
|
|
| 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 4In 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 4We 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).
|
|
| 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. |
|
| 21. |
What is the difference between getch() and getche()? |
|
Answer» Both these C FUNCTIONS read CHARACTERS from the keyboard, the only DIFFERENCE being:
Here is an example to demonstrate the difference between the two functions: #include<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: bgetch() 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:
|
|
| 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:
|
|