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 use of a CSS preprocessor? When should a pre-processor be utilised in a project, according to you?

Answer»

CSS preprocessors are scripting languages that augment CSS's STANDARD functionality. They allow us to employ variables, nesting, inheritance, mixins, functions, and mathematical operations in our CSS CODE. CSS preprocessors make it simple to automate repetitive activities, eliminate code bloat and errors, DEVELOP reusable code snippets, and maintain backward compatibility.

The benefits and drawbacks of using a preprocessor vary depending on the type of project, but the following are some of the benefits and drawbacks.

Advantages:

  • You may add variables and functions to CSS with CSS Preprocessor, which gives it a new dimension and scope, making development easier and more efficient. It also improves the organization and cleanliness of your code.
  • CSS Preprocessors is a unique feature that allows you to combine numerous stylesheets into one. You can make separate files for each screen or page, then combine them in the main CSS file.
  • The CSS Preprocessor assists you in avoiding REPETITIONS. Instead of rewriting common styles, you can write them once and then import them.
  • CSS class nesting makes it simple to target DOM elements and saves time. It's also a lot easier to alter CSS files due to nesting.

Disadvantages:

  • Preprocessing tools are required for preprocessors. The time they take to recompile can be lengthy.
  • Although the source files may be small, the output CSS may be large, causing the request to take longer to finish.

Choosing a preprocessor comes down to personal choice, and it MIGHT be instructive to see how a developer could choose one over the other for your project.

Useful Preparation Resources:

OOPs

OS

SQL

Practice Problems

2.

Describe the main differences between the LocalStorage and SessionStorage objects in context to HTML.

Answer»

The following are the main distinctions between LOCALSTORAGE and sessionStorage objects:

  • The data stored in the localStorage object has no expiration date. The sessionStorage object, on the other HAND, keeps data for a single session.
  • When a BROWSER window is closed, data in a localStorage object is not deleted. In the case of sessionStorage objects, however, the data is destroyed when the browser window is closed.
  • SessionStorage data is only AVAILABLE in the browser's current window. The data in the localStorage, on the other hand, can be shared ACROSS several browser windows.
3.

What makes a block-level element different from an inline element in HTML?

Answer»
BLOCKInline

A block-level element is drawn as a block that will always start on a NEW line and will stretch to occupy the full WIDTH AVAILABLE to it, i.e. the width of its container.

Examples of block-level elements by default: <div>, <img>, <section>, <form>, <nav>.

Inline items are drawn where they are defined and take up only the space that is required. Looking at how text flows on a page is the simplest approach to understand how they work.

Examples of inline elements by default: <span>, <B>, <strong>, <a>, <input>.

4.

What do you understand about RAID in context to Project Management?

Answer»

RAID stands for RISK, Actions, Issues, and Dependencies in PROJECT management. These are extremely crucial aspects for a project manager to understand.

  • Risks are potential pitfalls that COULD have a good or negative impact on the project, causing the final product to deviate from the original design.
  • The tasks that you do during the project are referred to as actions.
  • Issues are ROADBLOCKS that you may encounter over the COURSE of the project that must be effectively resolved or the project will be derailed or fail.
  • Decisions are the actions/tasks you choose in the project.
5.

Explain the Project Management Life Cycle method in context to Project Management.

Answer»

The Project Management LIFE Cycle is a set of activities/tasks that must be COMPLETED in order for project objectives or targets to be met. This assists in organizing and streamlining the efforts required to complete the project into a sequence of logical and doable actions. The Project Management Life Cycle is divided into four SIMPLE phases, as follows:

  • Initiation: It's the first and most important step in the project's life cycle, where the project's initial scope is determined and resources are allocated.
  • Planning: This step requires you to jot down a sufficient amount of detail for the project in order to PLAN time, cost, and resources. It calculates the amount of work required and effectively manages risk.
  • Executing: This step contains the processes that are utilized to complete the project management plan's work. It's all about meeting the project's goals. It also ENTAILS monitoring, assessing, and regulating the project's progress. You must also promptly recognize possible problems and take necessary action.
  • Closure: This step is a crucial aspect of project management, and it is responsible for completing all project activities. This entails completing all activities across all the steps, disbanding the project team, and using the project closure report to sign off on the project with the customer.
6.

What is EUCALYPTUS in cloud computing? List some of its functionalities.

Answer»

Eucalyptus is commercial and open-source computer software for creating private and hybrid CLOUD computing environments that are compatible with Amazon Web Services (AWS). It was created by the company Eucalyptus Systems. Eucalyptus stands for Elastic Utility Computing Architecture for Linking Your Programs To Useful Systems. Eucalyptus enables application workloads to be flexibly scaled up or down by pooling compute, storage, and network resources.

Some of its functionalities are:

  • Users can configure computing, network, and storage resources using the Eucalyptus USER Console. Using built-in key management and encryption capabilities, development and test TEAMS may control virtual instances.
  • Eucalyptus can run a variety of virtual machine images, including Windows and Linux. Users can create a library of Eucalyptus Machine Images (EMIs) that are detached from infrastructure details, allowing them to run on Eucalyptus clouds.
  • Eucalyptus supports storage area network devices that use storage arrays to boost performance and reliability. Direct-attached storage is also supported by Eucalyptus.
  • New features for AWS compatibility have been added to Eucalyptus 3.3. Resource tagging, for example, allows application developers and cloud managers to add configurable metadata tags to resources like firewalls, load balancers, Web servers, and particular workloads to help them be more easily identified.
  • Maintenance Mode in Eucalyptus 3.3 allows cloud managers to do maintenance on Eucalyptus clouds with no interruption to instances or cloud applications.
  • Better image management and migrating tools, warm UPGRADE capabilities, a hybrid cloud user console to handle both Eucalyptus and AWS resources, Identity and Access Management (IAM) roles, and ENHANCED High Availability (HA) capabilities are among the new features in Eucalyptus 3.4.
7.

What are the benefits of Hybrid Clouds in Cloud Computing?

Answer»

A hybrid cloud is computing, storage, and service environment that combines on-premises infrastructure, private cloud services, and a public cloud (such as Amazon Web Services (AWS) or Microsoft Azure) with orchestration among the platforms. Hybrid cloud infrastructure is one that combines public clouds, on-premises computing, and private clouds in your cloud server.

The real value of cloud services comes from their ability to enable a fast-paced digital company to change. There are TWO agendas in every technology management organization: the IT AGENDA and the BUSINESS transformation agenda. Traditionally, the IT agenda has been concentrated on cost-cutting. Digital business transformation plans, on the other hand, are concentrated on making money through investments.

The main advantage of a hybrid cloud is its FLEXIBILITY. To acquire the agility it requires for a competitive advantage, your company may desire (or need) to INTEGRATE public clouds, private clouds, and on-premises resources.

8.

How do the commands DROP, TRUNCATE, and DELETE differ in SQL?

Answer»
DROPTRUNCATEDELETE
DROP is USED for deleting a database, table, or a viewTRUNCATE is used for deleting all ROWS of a tableDELETE can either delete all of the rows at once or ONE by one. i.e., we can use it according to our needs.
No data can be rollbackedNo data can be rollbackedData can be rollbacked
It is a Data Definition Language (DDL) commandIt is a Data Definition Language (DDL) commandIt is a Data Manipulation Language (DML) command.
It deletes the entire structure of the table.It PRESERVES the structure of the table.It does not affect the structure of the table.
9.

What are the advantages and disadvantages of indexing in DBMS?

Answer»

Indexing is a technique for improving the database PERFORMANCE by reducing the number of disc accesses needed when a query is run. It's a data structure strategy for finding and accessing data in a database rapidly.

The following are some of the benefits of indexes:

  • An index allows data to be RETRIEVED quickly.
  • When an index is used in a query, the performance usually improves dramatically.
  • They're GOOD for sorting. It is possible to eliminate the need for a post-fetch-sort procedure.
  • The index ensures that each record in the database is UNIQUELY identified.

The cons of indexing are:

  • Inserts, updates, and deletes are all slowed down by indexes.
  • Indexes take up a lot of space (this INCREASES with the number of fields used and the length of the fields).
10.

What are the different types of Shells in Linux?

Answer»

SHELL is a PROGRAM that acts as the interface between the user and the operating system. It is a command-line interface to the Unix operating system. It collects data from you and runs programs depending on that data. The output of the program is displayed once it has completed its execution.

Shell allows us to run commands, programs, and shell SCRIPTS. Kernel maintains resources between processes and regulates all-important computer operations. It also restricts hardware access, organizes all performing utilities, and manages resources between processes. Only kernel users have access to the operating system's utilities.

Types of SHELLS:

  • The C Shell: It included aliases and command history, among other features. It has features like built-in math and C-like EXPRESSION syntax that make programming easier.
  • The Bourne Shell: It's the very first UNIX shell. It is more convenient and faster. It lacks interactive features such as the ability to recall past commands. It also has no built-in support for ARITHMETIC and logical expressions. It is the default shell for the Solaris operating system.
  • The Korn Shell: The Bourne shell is a subset of it. As a result, everything in the Bourne shell is supported. It includes interactive elements. Built-in arithmetic and C-like arrays, functions, and string manipulation facilities are among the features. It is more efficient than a C shell. It works with scripts written in the C shell.
  • The GNU Bourne-Again Shell: It can be used with the Bourne shell. It incorporates Korn and Bourne shell features.
11.

What are the advantages and disadvantages of time slicing in CPU Scheduling in OS?

Answer»

Time slicing allows a task to run for a set amount of time before returning to the pool of ready TASKS. The scheduler then determines the executable job depending on the priority and a variety of other factors. A task in a time-slicing method runs for a predetermined amount of time. If there is another task with a higher priority after that task is completed, the scheduler runs the priority task next, BASED on priority and other considerations. 

The advantages of time slicing in CPU Scheduling are:

  • CPU resources are distributed fairly. The kernel of our CPUs does not simply allocate all of our PCs' resources to a single task or service. Because the CPU is always running multiple processes that are required for it to function, our kernel manages these processes without delay.
  • It prioritizes all processes equally. The CPU accomplishes this by running processes one at a time, slice by slice. A time slice is a brief period of time that is allotted to a process and executed by the CPU.
  • It's simple to integrate into the system.
  • After a process has run for a set amount of time, it is interrupted and another process runs for the same amount of time. To save the states of preempted processes, the context switching approach is utilised. Hence, the states of the preempted processes are not lost.

The disadvantages of time slicing in CPU Scheduling are:

  • The processor output will be delayed if the slicing time is short.
  • It spends a lot of time switching between contexts.
  • The time quantum/slice has a significant impact on process management.
  • Processes do not have defined priorities.
  • Priority is not given to more vital jobs.
  • It's challenging to come up with an adequate time quantum/slice.
12.

List the important functionalities/features of an operating system.

Answer»

The following are some of the most important features of an operating system:

  • The operating system allows diverse applications and peripheral devices to share the computer's memory and central processing unit time.
  • Between the user and the computer hardware, an Operating System serves as a communication bridge (interface). A user interface, such as a graphical user interface or a command LINE, is provided by an operating system.
  • The ability to boot the computer is part of an operating system.
  • It manages the peripheral devices and does some simple activities like keeping a track of all devices connected to the system, DESIGNATING a program called the Input/Output Controller that is responsible for EVERY device, and so on.
  • It offers file management, which is the process by which an operating system maintains, fetches, manipulates, and saves data.
13.

Get the nth Fibonacci number in O(n) time and O(1) space complexity.

Answer»

//Javascriptfunction fib(n){ let [x, y] = [0, 1] while (n > 0){ [x, y] = [y, x + y] n -= 1 } return x}

This SOLUTION has a linear time complexity of O(n) and a constant space complexity of O(1). The number of loops required to determine the nth fib number will STILL increase linearly as n increases, but as we extend the sequence out, we are OVERRIDING the previous NUMBERS in the sequence, KEEPING the space complexity constant for any input n. It is often referred to as the Iterative Top-Down Approach.

14.

Write the code to find the LCM of an array of numbers.

Answer»

We know that LCM (x, y) = (x * y) / GCD (x, y). We have to extend this idea to an array of numbers.

Let's imagine we have an array arr[] with n members for which the LCM must be calculated.

Our algorithm's major steps are as FOLLOWS:

  • Set res = arr[0] as the first value.
  • Iterate over all of the array's elements, from i = 1 to i = n-1.
    Our lcm, which is stored in res, is LCM of (arr[0], arr[1],........, arr[i-1]) at the ITH iteration. LCM (arr[0], arr[1],...., arr[i]) = LCM (ans, arr[i]). As a result, we only need to do res = LCM (ans, arr[i]) = (ans * arr[i]) / gcd at the i'th iteration (ans, arr[i]).
//C++ PROGRAM to find the LCM of n elements of an array#INCLUDE <bits/stdc++.h>using namespace std; typedef long long int ll; //the function that finds//GCD of 'x' and 'y'int GCD(int x, int y){ if (y == 0) return x; return GCD(y, x % y);} //Driver Codeint main(){ int a[] = { 11, 7, 3, 9, 4 }; int len = sizeof(a) / sizeof(a[0]); // Initializing result which will store the lcm ll res = a[0]; // res contains LCM of a[0], ..a[i] // after i'th iteration, for (int i = 1; i < len; i++) res = (((a[i] * res)) / (GCD(a[i], res))); cout<<res<<ENDL; return 0;}

Output:

 2772
15.

Explain copy constructor vs assignment operator in C++.

Answer»

A copy CONSTRUCTOR is a member function that uses another object of the same class to initialise an object. Assignment operators are used to giving a variable a value. The assignment operator's left side OPERAND is a variable, while the assignment operator's right side operand is a value.

 // C++#include<iostream> #include<stdio.h> using namespace STD; class IB{ public: IB() {} IB(const IB &AMP;b) { cout<<"Copy constructor is called "<<endl; } IB& operator = (const IB &b) { cout<<"Assignment operator is called "<<endl; return *this; } }; // Driver codeint main() { IB b1, b2; b2 = b1; IB b3 = b1; getchar(); return 0; }

Output:

Assignment operator is calledCopy constructor is called

When a new object is GENERATED from an existing object as a copy of the old object, the copy constructor is called. When an already initialised object is given a new value from another object, the assignment operator is used.

16.

Explain free() vs delete () in C++.

Answer»

Both delete() and free() are USED to dynamically deallocate memory.

  • The free() function is a C library function that can ALSO be used in C++, whereas the keyword "delete" is a C++ keyword.
  • The delete operator DELETES a pointer that was allocated using the new operator or a NULL pointer, whereas the free() function deletes a pointer that was allocated with the malloc(), calloc(), or realloc() functions or a NULL pointer.
  • The delete operator in C++ invokes the class's destructor when it destroys the allocated memory, but the free() function does not; it just frees the memory from the HEAP.
17.

What do you understand about Stack Unwinding in C++?

Answer»

Stack Unwinding is the process of eliminating function ENTRIES from the function CALL stack at runtime. EXCEPTION Handling is often ASSOCIATED with Stack Unwinding. When an exception occurs in C++, the function call stack is searched linearly for the exception handler, and any entries before the function with the exception handler are deleted from the function call stack. If the exception is not handled in the same code, stack unwinding is REQUIRED (where it is thrown).

18.

Explain precondition and postcondition to a member function in the context of C++ programming language.

Answer»

A precondition is a condition that must be met before a member FUNCTION may be called. If PRECONDITIONS are never false, a CLASS is appropriately used. If a precondition fails to hold, the following function is not executed. For EXAMPLE, before inserting an element into a stack, we call the isfull() to check if the stack is full or not. Here, the isfull() is an example of a precondition.

A post-condition is a condition that must be true when a member function is exited if the precondition was true when the function was entered. For a code to be correctly implemented, the post-conditions must never be false For example, we know that isempty() must always hold after placing an element ONTO the stack. This is a push operation post-condition.

19.

Differentiate between strings and char arrays in Java.

Answer»
StringsCharacter Arrays
A string is a sequential COLLECTION of characters that are represented as a SINGLE DATA type.A Character Array is a collection of char data types in sequential order.
Strings are IMMUTABLE which means the data or state of a String object can't be modified once it has been created; instead, a new String object is generated.Character Arrays are mutable which means the contents of a char array can be changed.
Strings can be used with built-in functions like substring() and charAt().In Java, there are no built-in functions for working with Character Arrays.
The '+' operator can be used to join two strings together to GENERATE a new one.Appending two Character Arrays with '+' is not possible.
The charAt() method is used to access characters in a String at a specific index.[] can be used to access the characters in a Character Array in the same way it can in any other language.
Strings can be stored in memory in any manner.Character Array elements are sequentially stored at increasing memory places.
The String Constant Pool contains all Strings.The Heap contains all Character Arrays.

The toCharArray() function of the String class can be used to transform a String into a Character Array.

Eg: String s = “GEEKS”;

char [] ch = s.toCharArray();

The code above converts a string into a char array.

A String Constructor can be used to transform a Character Array to a String.

Eg: char[] a = {‘G’, ‘E’, ‘E’, ‘K’, ‘S’};

String A = new String(a);

The code above converts a char array into a string.

20.

What are the differences between error and exception in Java?

Answer»

An error occurs when a user performs an unauthorised action that causes the code to behave abnormally. Errors in programming are frequently UNNOTICED until the code is compiled or run. Some of the errors make it impossible to compile or run a program. As a result, errors should be removed before COMPILING and running a program. Out of memory and system crash are two examples of errors.

In Java, an exception is an unwelcome or unexpected occurrence that occurs during the program execution, or during run time, and disturbs the usual flow of the program's instructions. Exceptions are circumstances that arise during the program execution and may result in its termination. However, try, catch, and throw keywords can be USED to recover them.

Unchecked exceptions (exceptions which are not checked at compile time), such as ArrayIndexOutOfBoundException, are KNOWN to the compiler at runtime, whereas checked exceptions (exceptions which are checked at compile time), such as IOException, are known to the compiler at compile time.

ErrorsExceptions
It is not feasible to recover from an error during compilation and execution.Exceptions can be RECOVERED by utilising a try-catch block or by throw keyword.
In Java, all errors are of the unchecked type.There are exceptions for both checked and unchecked types.
The environment in which the code is running is the most common cause of errors.Exceptions are generated by the code itself.

Errors can arise both at compile and run time.

Compile Time: eg Syntax Error

Run Time: Logical Error.

All exceptions occur at runtime.
Errors are defined in the java.lang.Error package.Exceptions are defined in the java.lang.Exception package
Examples : java.lang.StackOverflowError, java.lang.OutOfMemoryErrorExamples : Checked Exceptions : SQLException, IOException Unchecked Exceptions : ArrayIndexOutOfBoundException, NullPointerException, ArithmeticException.
21.

Explain Aggregation vs Composition in Java.

Answer»

An association is a relationship that exists between two distinct classes and is established through their Objects. One-to-one, one-to-many, many-to-one, and many-to-many associations are all possible.

An Object communicates with other Objects to leverage the capabilities and services provided by that object in Object-Oriented programming. Association has two forms and they are composition and aggregation.

Aggregation is a unique type of association in which:

  • It denotes a Has-A relationship.
  • It's a one-way relationship or a unidirectional association.
  • In Aggregation, both entries can PERSIST independently, IMPLYING that terminating one entity will have no influence on the other.

In the above image, we can clearly see that each teacher is associated with a college, and each student is also associated with a college. Thus, both the entities, the student and the teacher can exist independently. 

Composition is a type of Aggregation in which two entities are extremely reliant on one another.

  • It denotes a part-of-relationship.
  • Both entities are reliant on one another in composition.
  • When two entities COME TOGETHER to form a composition, the composite object cannot exist without the other.

In the above image, we can clearly see that both TYRE and Engine form an integral part of a vehicle. Both are reliant on each other. Without either of them, the Vehicle entity is useless.

22.

How can you make a request for garbage collection in Java?

Answer»

There are two ways to ask the JVM to run the Garbage Collection.

  • The garbage collection methods are available in the Runtime CLASS given by Java. For any Java program code, the Runtime class is a singleton. A singleton instance of the Runtime class is returned by the function getRuntime(). This instance of Runtime can be used to call the gc() function to request garbage collection.
  • Request the JVM to PERFORM GC USING the System class System.gc() function.
 public class Sample{ public static void main(String[] args) throws InterruptedException { Sample s1 = new Sample(); Sample s2 = new Sample(); // Making the reference VARIABLE as null s1 = null; // Calling the system call function for garbage collection System.gc(); // Making the reference variable as null s2 = null; // Calling for garbage collection through the getRuntime() method Runtime.getRuntime().gc(); } @Override // This method is called on object once before garbage collecting it protected void finalize() throws Throwable { System.out.println("Garbage COLLECTOR has been called"); System.out.println("The Object whose garbage has been collected is : " + this); }}

Output:

Garbage collector has been calledThe Object whose garbage has been collected is : Sample@4251f172Garbage collector has been calledThe Object whose garbage has been collected is : Sample@481e8172

Explanation:

In the above code, we create two instances of a class and then re-initialize it to null. Then we call for the garbage collection using the two methods specified above. Thus, we get the above output.

23.

What do you understand about order of precedence and associativity in Java, and how do you use them?

Answer»

Order of precedence:

The operators are arranged in order of precedence. When a number of operators are employed in an expression, the priorities of the operators determine how the expression is evaluated. In an expression CONTAINING multiple operators with various PRECEDENCES, operator precedence decides which one is executed first.

Order of precedence example:

(4 > 2 + 8 && 3)

The following expression is the same as:

((4 > (2 + 8)) && 3)

The expression (2 + 8) will be executed first, yielding a value of 10.

After the first HALF of the equation (4 > 10) executes, the output is 0 (false).

Finally, (0 && 3) runs and returns 0. (false).

Associativity:
When two operators with the same precedence EXIST in an expression, associativity is employed. Left to right or right to left associativity is possible. To determine whether an expression is evaluated from left to right or right to left, associativity is used.

Associativity example:

 12 * 2 / 4

Operators * and / have the same precedence in this case. "*" and "/" are both left to right associative, which means that the expression on the left is executed first and then moves to the right.

As a result, the preceding expression is identical to:

((12 * 2) / 4) i.e., (12 * 2) executes first and the result will be 24 (true) then, (24 / 4) executes and the final output will be 6 (true)
CATEGORYOPERATORASSOCIATIVITY
Postfix++ – –Left to right
Unary+ – ! ~ ++ – –Right to left
Multiplicative* / %Left to right
Additive+ –Left to right
Shift<< >>Left to right
Relational< <= > >=Left to right
Equality== !=Left to right
Bitwise AND&Left to right
Bitwise XOR^Left to right
Bitwise OR|Left to right
Logical AND&&Left to right
Logical OR||Left to right
Conditional?:Right to left
Assignment= += -= *= /= %=>>= <<= &= ^= |=Right to left
24.

What are the differences between an object-oriented programming language and object-based programming language?

Answer»

The FOLLOWING are the main differences between object-oriented and object-based LANGUAGES.

  • Object-oriented languages adhere to all Object Oriented Programming concepts, but object-based languages do not adhere to all Object Oriented Programming concepts such as inheritance, polymorphism, etc.
  • Object-oriented languages lack built-in objects, but object-based languages do. For example, JavaScript contains a built-in window object.

Java, C#, Smalltalk, and others are examples of object-oriented programming languages while JavaScript, VBSCRIPT, and others are examples of object-based languages.

25.

What makes a macro faster than a function in the C programming language?

Answer»

Macros are sections of code in a programme that have been given a name. The compiler substitutes this name with the real piece of code whenever it encounters this name. To define a macro, use the '#define' directive. Macros can be defined either before or within the main method. 

Code 1:

//C#include<stdio.h> #include<conio.h> #define HRS 24 //Macro int main() { printf("%d", HRS); return 0; }

Output:

24

Explanation:

In the above code, we defined a macro NAMED HRS to have a VALUE of 24. Now, when we call the macro in the printf function, 24 GETS printed in the output terminal.

The above code can be INFERRED to be the following code without the use of macros.

Code 2:

//C#include<stdio.h> int hrs() { return 24; } int main() { printf("%d", hrs()); //calling return 0; }

Output :

 24

Explanation:

Here, we defined a function named HRS. When we call the HRS function in the printf function, the function returns 24 and so 24 is printed on the output terminal.

Macros are pre-processed, which implies that all macros are processed before the code is compiled, and functions are processed after the code is compiled.