Virtusa Interview Questions

The most crucial tool in a software engineer's toolbox is programming knowledge. You might as well not be there if you can't code. Your code's flawless grammar is meaningless if a programmer cannot comprehend it or recreate it. You must be able to express yourself in programming languages and tools and think like a programmer. Programming questions come in various shapes and sizes, but they all test your capacity for logical thought and your programming skills. These questions probe your knowledge until you discover the solution rather than directly testing your typing speed or memory recall. And that's what took place during the entire Virtusa Interview procedure.

Virtusa Corporation is a technology services company with headquarters in the United States that was founded in Sri Lanka in 1996. The company provides multinational organizations and software developers with IT consulting, business consulting, system implementation, and application outsourcing services. The biggest Virtusa delivery centers are located in Hyderabad, Chennai, and Colombo. Virtusa also has multiple distribution centers in Sri Lanka. The company was purchased by Baring Private Equity Asia in February 2021 for $2 billion.

Top 10 Frequently Asked Virtusa Interview Questions

  1. Difference between Thread and Runnable in Java.
  2. Provide some information on DHCP.
  3. What is your knowledge about DNS?
  4. What is TCP/IP Protocol?
  5. What does Java's collection framework mean?
  6. Describe Servlet.
  7. What is REST API?
  8. Explain the DBMS's ACID Property.
  9. Use an effective algorithm to find a value in a m x n integer matrix.
  10. Java HashMap Implementation

Virtusa Recruitment Process

Interview procedure at Virtusa

A poll indicates that an applicant has a 95% chance of being placed if they pass Virtusa's first three rounds (the online test, the technical test, and the group discussion). The HR interview at Virtusa Companies is comparable to those at many IT companies. Much of the conversation in an interview is one-on-one. The basic introduction and expectations for the bundle will come first. They will also assess your technical knowledge in addition to this.

Fundamentally, the three topics below will be the focus of whatever questions they pose.

  • based on the candidate's skill set.
  • Real-world examples of managing a team.
  • Prior experiences, the nature of the task, problems, and how those challenges were resolved.

Interview Process 

Virtusa employs both on-campus and off-campus freshmen. The interview procedure is the same for both categories of applicants. Virtusa also employs people from employee recommendations in addition to those who apply through the career portal.

Process of a Virtusa Interview

  • Round 1: Virtusa Online Technical Aptitude Assessment.
  • Round 2: Virtusa Technical Interview Round.
  • Round 3: Virtusa HR Interview Round.

Interview rounds 

  • Round 1 of the Virtusa Online Technical Aptitude Assessment is the round for evaluating technical aptitude online. This consists of 60 MCQs, all of them are technical in nature. Operating systems, Computer Networks, Database Management Systems, Object-Oriented Programming (Java & C/C++), and Data Structures and Algorithms are the topics that handle these technological problems. Beginning in 2022, the business will also start questioning code snippets to identify flaws and forecast results. The test will take 90 minutes to complete.
  • Round 2 of the Virtusa Technical Interview Round will focus on technical questions. In this round, the interviewer begins by asking fundamental questions on the basics of computers before moving on to more questions about Object-Oriented programming. Also, the interviewer will quiz you on Java's fundamentals. When thoroughly studied, the question will be of medium difficulty and be simple to answer. Also, the interviewer will enquire about the projects you worked on. The project discussion is crucial since virtusa employs software engineers with some software development knowledge. The whole interview time will be between 1.5 and 2 hours at most.
  • The third phase will consist of an HR interview round for Virtusa. The interviewer didn't bring up any technical issues during the conversation. They largely examined the applicant's modes of thought and communication. The salesperson didn't enquire about any technology or goods from Virtusa. Instead, they emphasized the applicant's capacity for persuasion and communication. They were looking to discover if the applicant was open and honest. Their inquiries would all be about the business. As a result, it's critical to become familiar with the company's profile.
  • Virtusa also organizes Virtusa Neural Hack, a national-level coding competition. The participants must use Java, C++, and Python programming languages to answer the four questions. The winner will receive a prize from Virtusa and have the chance to be hired there as well. The other applicant who did not win the prize but did well in the competition would often receive an interview from Virtusa based on the shortlisting criteria.
  • What Makes You a Good Recruit for the Company?

The most important thing is to convince your potential employer to choose you over other applicants. Your response must be succinct and useful and describe how you can assist the business in achieving its objectives. You must refrain from promoting your abilities in your response, but you must also steer clear of making sweeping generalizations. You should refrain from saying things like, "I would love to work here since the company is excellent," or "I want to join the company because it sounds like a great place to work." Instead, discuss why you value the organization and how you can assist it in achieving its objectives.

  • What Can You Contribute to the Organization?

HR interviews can be a fantastic opportunity to demonstrate how you fit within the culture of the organization. Be prepared to talk about how you can add to the company's culture and overall culture. You can also highlight a few of the ways your prior employment benefited the sector or business. If you are applying for a job at a startup, for example, you can explain how your prior experience working for a startup relates to your qualifications for the position.

  • Why Should We Choose You Instead of the Other Candidate?

You can respond to this query by describing how you meet the needs of the business. Describe why you are a good fit for the organization and how your abilities can help it achieve its objectives. You might also discuss your professional background and how it connects to the demands of the firm. For instance, if you are applying for a job at an accounting firm, you can talk about your prior accounting-related work experience and how it connects to the company's objectives.

  • Why Should We Choose You Instead of the Other Candidate?

You can respond to this query by describing how you meet the needs of the business. Describe why you are a good fit for the organization and how your abilities can help it achieve its objectives. You might also discuss your professional background and how it connects to the demands of the firm. For instance, if you are applying for a job at an accounting firm, you can talk about your prior accounting-related work experience and how it connects to the company's objectives.

  • Please assess my interviewing skills on a scale of one to ten.

Candidates frequently think that receiving a score of 10 out of 10 will increase their chances of landing a job. This is untrue, though. Interviewers use the questions they ask to gauge a candidate's diplomatic abilities. Yet you must respond to this. There are numerous possible responses, but one of the finest might be: "In my perspective, I am not the correct person to judge you." Because of your excellent qualities, you are present. I'm glad to speak with you, though.

  • What qualities do you have?

You qualify to be the best applicant for the position based on your strengths, which set you apart from the competition. The interviewer might ask this question to see if your abilities and qualifications match what they are looking for in candidates. Strengths are characteristics you have or have demonstrated in the past that make you a great fit for the position. Work ethics, creativity, and personality are just a few examples. Prepare yourself to discuss your prior experiences while concentrating on your strong points. Don't merely include cliched traits like "I work well in a team" or "I'm always eager to learn new things." What distinguishes you from the competition?

  • What are your areas of weakness?

Your advantages might actually be your disadvantages. Yet, weaknesses are typical traits that are absent from a person. They don't automatically rule you out of a job but make you a less-than-ideal prospect. The interviewer may use this query to assess your suitability for the position. This is a question that your interviewer may ask you to determine whether it makes any sense to them. It asks, "Do your abilities and skills match the requirements of the job?" If you are missing in a certain area and it does not make sense to them or the job description, you can be asked to discuss your deficiencies in the interview.

Virtusa Technical Interview Questions For Freshers

1. Provide a thorough explanation of binary search. How does it function? Apply it as well.

One of the most often used algorithms in computer programming is binary search. It is used most often in computer applications since it is so widespread. You can tell that binary search is highly helpful by examining how frequently it appears in various programming languages. The quicker approach, binary search, can help to seek the element in just O(log n) time. The element's order must be sorted in order for a binary search to function.

Due to the list's sorted nature, Binary Search adopts the strategy of removing any elements that are unnecessary. The absence of the element it is confirmed. The binary search is used to find the key in the list at this location, which helps to identify which side of the position the key must be on in the list. This is done in order to make this approach feasible. The middle point in the list is located through binary search, which then compares it to the key.

It returns true, indicating that the key was discovered in the list if the element matches the key. If not, it verifies with the element which sides the key must be present in the list. The algorithm then removes the other half in light of this. And every iteration of it does this. This is how a binary search eliminates half of the list after each iteration. Thus, it requires O(log n) time to eliminate half.

Implementation of Binary Search using Java-

public boolean binarySearch(int[] arr, int low, int high, key){
        //base case returns false when index is out of bound 
        if(low > high) 
            return false;   
        int mid = (low+high)/2
        //Searching on mid if key found then return true
        if(arr[mid] == key) 
            return true
        //Searching on right sub array if key exist there
        else if(arr[mid] < key) 
            return binarySearch(arr, mid+1, high, key);
        //Searching on left sub-array of key exist there.
        else
            return binarySearch(arr, low, mid-1, key);
    }

2. The distinction between a database's left join and right join.

You use the Left Join operator when you want to combine two tables where certain columns have both primary and foreign keys. Only those rows will be returned from the query if the left table contains a column with primary key values. The result set will contain all rows if a primary key column is not specified. Any rows in the right table that match any values in the left table are returned by a right join. The left join returns any rows that match any values in the left table. The distinction between the Left Join and Right Join operators also exists here. While the Left Join operator is used when tables have columns supporting equality, the Right Join operator is used when tables have columns not supporting equality.

If you want to enrich your career and become a professional in Java, then enroll in "Core Java Training" - This course will help you to achieve excellence in this domain.

3. Difference between Thread and Runnable in Java.

Java's Thread class has an interface called Runnable. The functionality and methods of implementation of these two differ greatly from one another other from this. They are:

Thread

  • A class is a thread. This facilitates the Java program's ability to start a new thread.
  • The class includes numerous methods, such as start() and run ()
  • For each thread, an object is created and associated
  • Because a distinct object is created, additional memory is needed.
  • A class that extends Thread is unable to extend another class because Java forbids multiple inheritances.

Runnable

  • Threads can be formed utilizing the runnable functional interface.
  • The run is the single abstract method on this interface ()
  • There may be several threads that share the same item.
  • Less memory is required because of the common objects.
  • If the class implements the runnable interface, it can be expanded to another class.

MindMajix Youtube Channel

4. When should a function throw an exception?

Keywords, like try and catch, are used to handle exceptions. But, we can use the keyword throw in the method declaration if we don't want to handle the exception in the method on which it may arise. This implies that the method that is calling this one must have dealt with the exception. Consider a method that accepts two integers, divides them, and then returns the outcome. Hence, the procedure will raise an exception if the calling function passes 0 as the argument. Hence, in this situation, we can include the throw keyword in the add method declaration to indicate that the method may throw an exception. 

5. What is the use of the ‘super’ keyword inside the constructor?

The Super keyword in the constructor is used to invoke the parent class constructor. Generally, when a subclass extends the parent class, and the parent class has a parameterized constructor. If we create the child class object, then the parent's default constructor will be invoked implicitly. Since we need to initialize the object with some value, so we need to explicitly call it from the child class constructor using the super keyword.

6. Provide some information on DHCP.

A device can automatically receive an IP address and other network settings from a DHCP server using the Dynamic Host Configuration Protocol (DHCP). This can be helpful if you have a large network and want to assign each device a unique IP address or if you don't want to allocate IP addresses to devices on your network manually. Many routers have a built-in DHCP server, but you may also set one up on your computer to provide devices on your network IP addresses.

7. What is your knowledge about DNS?

An IP address, such as 13.227.138.126, is generated from a domain name, such as www.mindmajix.com, by the Domain Name Server (DNS). This is known as querying in technical terms. If you wanted to enter https://www.mindmajix.com into your web browser, you would utilize DNS. If you input the domain name interviewbit.com instead of just the domain name, the DNS will seek the IP address for that domain. IP addresses are more difficult to remember than names, which is fantastic. Use a DNS server, which can be set up to return the appropriate IP address for a specific hostname, to prevent having to memorize the IP addresses of all the devices on your network. Either a server or a single computer can be used for this.

8. List a few shortcomings of the traditional waterfall model.

The traditional waterfall model has a number of drawbacks. Thus, we utilize different software development lifecycle models that are based on it instead of using it for actual projects. These models' primary flaws are as follows:

  • In the traditional waterfall paradigm, software develops from one phase to the next without any feedback path. Developers are regarded as being error-free at all times. Because of this, it lacks a mechanism for fixing mistakes.
  • Change requests are challenging to accommodate because this paradigm presupposes that all client requirements can be predicted in advance when customer requirements are always changing in practice. It is challenging to fulfill any change requests once the requirements specifications process is through.
  • There isn't any phase overlap: This paradigm advises beginning a new phase after the prior one is finished. This, however, is impossible to sustain in actual projects. Phases may cross over to improve effectiveness and cut expenses.

9. What is TCP/IP Protocol?

Computers communicate with one another using a network protocol called TCP/IP (Transmission Control Protocol/Internet Protocol). It serves as the backbone of the internet and governs how we download content from it. Transmission Control is referred to as TCP, while Internet Protocol is referred to as IP. These two phrases describe how data is transferred between computers when used together. TCP/IP is comparable to a data highway system. TCP and IP are the separate pairs of lanes for each connection. Data goes through this system in a defined way and abides by the guidelines established by each lane. For instance, a lane is the term used to describe your path if you are walking down a motorway. It's referred to as a motorway or an interstate if you're driving.

You can only move your car in one of these two directions at once; you cannot move it in both directions simultaneously. The data that passes through your computer is no different. Separate lanes must be used for each direction because only one direction of data can be sent at a time (for example, 1st Lane – Download; 2nd Lane – Upload).

You can instantaneously share files with anyone using TCP/IP over the internet and with other computers that have TCP/IP enabled on their network ports if you have the proper software installed on your computer.

10. Difference between set and list.

A list is an ordered collection of values where each value can be retrieved using a numeric index. A set is an unsorted group of values that, once generated, cannot be changed. Lists are ordered (beginning at 0), whereas sets are unordered. This is the primary distinction between the two types of data.

Sets have a variety of uses, including:

  • They can be used to store data in a specific sequence, such as a list of phone numbers, the months of the year, or the days of the week.
  • When files are copied, sets can be used to maintain their original order (for instance, while sharing data with a person who doesn't have the same software tools).
  • They can be used to depict a limited population whose individuals are all distinct (e.g., all people born in New York City).
  • They can be used to represent random events where each participant has an equal chance of occurring (e.g., rolling dice).
  • Moreover, they can be used to keep particular instances of items (e.g., all forks from your kitchen drawer).

11. What does Java's collection framework mean?

An object library of classes known as a collection framework offers generic methods for building, querying, sorting, and iterating over collections of objects. In other words, it has the components required to develop unique collection types. Unlike conventional APIs like Java, a collection framework can be used to develop novel data structures that are not included in the JDK itself. util.Collection. As a result, programmers may easily design new collections that have features in common with JDK collections already in use. Numerous frameworks like Google Guava and Apache Commons Collections offer this idea. Yet not every collection structure is made equal. When selecting a collection framework for your project, it's crucial to make a good decision because a bad design can result in memory leaks or flaws that are challenging to debug.

12. What is Object-Oriented Programming?

The process through which a computer program objects is known as object-oriented programming. These are the items that the computer can make use of.

Classes and instances are two different kinds of things. Whereas instances represent specific objects, classes represent the attributes and behavior of an entity. You can think of objects as data containers. Everything has a distinct identity and can have a variety of characteristics and behaviors. The instance represents what it does, while the class represents what it is (the property) (its behavior).

Software that replicates relationships and procedures seen in the actual world is made using object-oriented programming. A car, for instance, might be represented as an object having characteristics like color and make as well as actions like start and stop.

The user interface can be seen as an object with properties like position on the screen and font size, as well as functions like enabling keyboard or touchscreen input or updating the car's position on the screen as the user moves it.

13. Describe Servlet.

A servlet is an element of a web application that can handle incoming HTTP requests. Servlets are in charge of carrying out the logic necessary for the web application to provide its data to end users and manage any necessary database interactions. Many computer languages, including Java, PHP, and Ruby, can be used to create servlets. The use of the Servlet API to define servlets is the most crucial fact to understand. A servlet can be thought of as an HTTP request handler—a section of your program that watches for incoming requests, handles them, and then sends the answers back to the client.

14. What is REST API?

The architectural style known as REST API (Representational State Transfer) is used to describe the exchange of data across web services. Request and response, PUT and GET, and resource and representation are the three types of interactions covered by REST. Standard HTTP requests can be used to carry out these interactions, but REST also offers a contract that specifies the kinds of data that can be delivered, how it can be formatted, and how it can be manipulated. Fewer data transmission over the network is the idea behind REST API. It accomplishes this by specifying the method to be used and how data will be transmitted (either PUT or POST) (GET or DELETE).

The requirement that both client-sender and server-receiver follow to a set of rules that specify how data will be conveyed (e.g., which format/data format) is another important feature of REST API. When these two factors work together, remote communication is more secure, and no information may be transferred between devices unless all parties explicitly consent to it.

Because it minimizes complexity while assuring interoperability between web services, REST API has grown in popularity as an architectural style for modern web applications. The REST API concept may appear straightforward at first, but there are a number of complexities to consider while developing an application using this architectural style. REST API, in particular, needs both clients.

15. Explain the DBMS's ACID Property.

"Atomicity, Consistency, Isolation, and Durability" is referred to by the acronym ACID. Consistency between internal database data and external data sources, such as a file system, is a feature of a database system. The data must be consistent across all areas if a property is absent in one.

The expression for the ACID property is

  • Atomicity - Only modifications that are explicitly authorized by a transaction are permitted to occur in the database system.
  • Consistency - The database's internal and external data sources must be accurate. This is accomplished by preventing transactions from trying to change the same records multiple times.
  • Isolation - Transactions must proceed independently of one another. For instance, both transactions are likely to fail if one edits a record that another transaction is changing.
  • Durability: After completing a transaction, all records must be written back to their original position with no damage.

Check Out: DBMS Interview Questions

Virtusa Technical Interview Questions For Experienced

16. Describe Garbage Collection in Java.

Garbage collection is the process of reclaiming memory space used by objects that are unreachable or no longer have a reference (i.e., an owner). The Java Virtual Machine (JVM) automatically performs garbage collection when the program runs out of memory. Java applications automatically perform rubbish collection to release unused memory when they run out of space.

The JVM recovers the following sources of consumed space:

  • Allocation of objects occurs on the controlled heap (per-thread space managed by the JVM).
  • The native heap, which is unmanaged storage that the VM contains, is where objects are allocated.
  • specialized caches like an interpreter's cache and a JIT compiler's cache.

Java programs allot objects by default on the managed heap. During garbage collection activities, objects on the managed heap are released depending on their lives, which include when they were created, when they were last accessed, and when their last reference count was recorded. Objects can be immediately liberated once another object no longer references them. A separate garbage collection procedure must be used to reclaim an object if it was referred to more than once before being last accessed.

17. A target number and a list of numbers are provided to you. You must provide the index of two numbers in a way that when its components are added, the result equals the target.

You might believe there must be a solution. For instance, arr = [2,9,1,3,4] output = [1,3] with target = 12

Picking every element and then identifying the one that adds up to the aim is a naive approach. This method may require some O (n2). By updating the index each time, we can see that we are repeating the same work. Therefore, one thing we can do is keep in a hash map the index of the element that we have already visited.

//This method returns the index of the two-element that sum to the target.
public int[] solution(int[] nums, int target) 
int val = 0
// HashMap that stores the index of the element that are required
// to sum to target
HashMap<Integer, Integer> hm = new HashMap<>();
hm.put(nums[0], 0);
for(int i = 1; i < nums.length; i++){
val = target - nums[i];
//Returning the solution of the element found.
if(hm.containsKey(val)){
return new int[]{hm.get(val), i};
}
// Adding the element to the hashmap so that it may be needed
// for future element
hm.put(nums[i], i);
}
return new int[]{0,0};
}

18. Create a program that decodes a URL string into a smaller form. The precursor of "https://www.tinyURL/encoded string>" must be present in the output URL.

For example - 

Input URL = “Leading Online Training & Certification Course Platform - MindMajix” 

The Output will be - “https://www.tinyURL/xsf34”

We can do one thing to solve this problem we can create an index that will be used as an index such that it can map to the long URL. And when it wants to access, it can be accessed constantly.

The code implementation can be -

public class encodeURL{
HashMap<String, String> hm = new HashMap<>();
//Method that generates an encoded URL that will be used as index.
private String generateHashURL(){
String AlphaNumericString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 
+"0123456789"
+"abcdefghijklmnopqrstuvxyz";
StringBuilder sb = new StringBuilder(1
for (int i = 0; i < 10; i++) {
int index = (int)(AlphaNumericString.length() * Math.random());
sb.append(AlphaNumericString.charAt(index));
}
//This creates a random string and returns it.
return sb.toString();
}    
// Encodes a URL to a shortened URL and returns it.
public String encode(String longUrl) {        
String predecessorURL = "https://www.tinyURL/";
String hashURL = predecessorURL+generateHashURL();
while(hm.containsKey(hashURL)){
hashURL = predecessorURL+generateHashURL();
}
hm.put(hashURL, longUrl);
return hashURL;
}
}

19. Create a program to reverse x's digits while keeping the value's range within a signed 32-bit integer. Return 0 if reversing x causes the value to deviate from that range.

For instance:

Input- 54678 Output: 87645

Input- 2147483647 Result - 0 (because reversing it goes out of bound to an integer.)

Since we need to store the maximum integer, that is also impossible with the integer data type. As it goes out of bounds. So we can either use a data type long or the other that can be easily identifiable. In this solution, we will use the char data type to do that. So here is the solution to that.

//Method will reverse the integer and return it.

public int reverse(int x) {

//Convert the number to a character array to reverse.

char [] ans = Integer.toString(x).toCharArray();

//Storing max and min possible value for boundary case

int maxAllowedPos = 2147483647;
int maxAllowedNeg = -2147483648; 
if(x > 0){
int i = 0, j = ans.length-1;
while(i < j){
char c = ans[i];
ans[i++] = ans[j];
ans[j--] = c;
}
String an = new String(ans);
double t = Double.parseDouble(an);
if(t > maxAllowedPos)
return 0;
return (int)t;
}else{
int i = 1, j = ans.length-1;
while(i < j){
char c = ans[i];
ans[i++] = ans[j];
ans[j--] = c;
}
String an = new String(ans);
double d = Double.parseDouble(an);
if(d < maxAllowedNeg)
return 0;
return (int)d;
}
}

 20. Rotate an array by k degrees to the right, assuming the array is initially positioned in that direction. Write a program for that.

//Method that rotates the array.
public int[] rotate(int[] nums, int k) {
        int n = nums.length;
        if(n == 1)
            return;
        //Determining the exact k number of steps to rotate
        if(k > n)
            k = k%n;
        //Finding the index from which the array has to be rotated.
        int i = n-k, j = 0;
        //Creating the auxiliary array that stores the reversed array.
        int [] auxArray = new int[k];
        //Traversing the and storing the elements that are unreversed.
        while(i < n){
            auxArray[j++] = nums[i++];
        }
        i = n-1;
        //reversing the remaining element to the array answer.
        while(i >= k){
            nums[i] = nums[i-k];
            i--;
        }
        return auArray;
     }

21. Two non-empty linked lists that represent non-negative integers are provided to you. Each list's node has one digit, listed in reverse order of the most important digit. Return the two totals as a linked list after adding them.

class Solution {
    private int val = 0;
    private int carry = 0;
    //This method reverse the linked list.
    private ListNode reverse(ListNode head){
        if(head == null || head.next == null)
            return head;
        ListNode t = reverse(head.next);
        head.next.next = head;
        head.next = null;
        return t;
    }
    // This method takes the 2 linked list and creates a new linked list with answer.
    private ListNode addNumber(ListNode l1, ListNode l2){
        //The approach used is the same as the normal arithmetic we learn during school days.
       //We keep count of the carry and create the node from that.
        if(l1 == null && l2 != null){
            val = l2.val + carry;
            carry = val/10;
            ListNode n = new ListNode((val%10), addNumber(l1, l2.next));
            return n;
        }
        else if(l1 != null && l2 == null){
            val = l1.val + carry;
            carry = val/10;
            ListNode n = new ListNode((val%10), addNumber(l1.next, l2));
            return n;
        }
        else if(l1 != null && l2 != null){
            val = l1.val + l2.val + carry;
            carry = val/10;
            ListNode n = new ListNode((val%10), addNumber(l1.next, l2.next));
            return n;
        }
        else{
            if(carry != 0)
                return new ListNode(carry);
            return null;
        }
    } 
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        l1 = reverse(l1);
        l2 = reverse(l2);
        l1 = addNumber(l1, l2);
        return reverse(l1);
    }
}

22. Find out if the given string s only contains the characters "(," ")," "," "," "[," and "]." To achieve this, first identify all the characters (such as "[", "]", "," and "(') and "(' and ")") that are not brackets.

Then check to determine whether any remaining characters are brackets (such as "," "," "(," and ")"). Output true if the string is valid. If not, the result is false. The output is false if the string is invalid.

We can use the stack to test the expression. The solution can be like this -

//This method returns true if the expression is valid. Otherwise false.
public boolean isValid(String s) {
int n = s.length();
if(n%2 != 0)
return false;
// Created a stack to keep count of the valid parentheses.    
char[] stack = new char[n];
int top = -1;
//Looping and pushing and popping the element from the stack-based 
//on it's validity 
for(int i = 0; i < n; i++){
char ch = s.charAt(i);
if(ch == '(' || ch == '{' || ch == '['){
stack[++top] = ch;
}
else{
if((ch == ')') && (top == -1 || stack[top] != '('))
return false;
else if((ch == '}') && (top == -1 || stack[top] != '{'))
return false;
else if((ch == ']') && (top == -1 || stack[top] != '['))
return false;
top--;
}
}
// If the stack is empty then the parentheses are valid. So return true
if(top == -1)
return true;
//Otherwise return false
return false;
}

23. Create a program that checks the array nums to see if any element appears at least twice and returns true if it does. Return false if each element is unique.

By maintaining the element in the HashMap, we can find a solution to this issue. Moreover, we must return true if any of the elements seem to exist already. And HashMap facilitates this for us.

//Method that returns the boolean if element found duplicate or not
public boolean containsDuplicate(int[] arr) {
//LENGTH OF THE ARRAY
int n = arr.length;
//IF ONLY ONE ELEMENT RETURN FALSE
if(n == 1){return false;}  
//FOR STORING THE ELEMENTS
HashSet<Integer> set = new HashSet<>();
//O OT N IF ANY ELEMENT ALREADY PRESENT
//RETURN TRUE
for(int i =0; i<n; i++)
{
if(set.contains(arr[i])){return true;}
set.add(arr[i]);
}
//IF NO DUPLICATES PRESENT RETURN FALSE
return false;
}

24. Use an effective algorithm to find a value in a m x n integer matrix.

The following qualities need to be present:

A row of integers is arranged in ascending order from left to right, and the first integer in each row is larger than the last.

Since we know that the matrix is already in a sorted position, we can apply binary search in each row, and then on the particular row, we can search for the value in that particular column. This is how we can solve this problem efficiently in O(log m + log n) times. The implementation of this solution will be -

class Solution {
//Applying binary search algorithm to the matrix on each column.
private boolean binarySearch(int[][] mat, int i, int low, int high, int target){
if(low > high)
return false;
int mid = (low + high)/2;
if(mat[i][mid] == target)
return true;
else if(mat[i][mid] > target)
return binarySearch(mat, i, low, mid-1, target);
return binarySearch(mat, i, mid+1, high, target);
}
public boolean searchMatrix(int[][] mat, int target) {
int m = mat.length; 
int n = mat[0].length;
//Searching every row by binary search tosearch for the element.
for(int i = 0; i < m; i++){
if(target < mat[i][0])
return false;
if(target >= mat[i][0] && target <= mat[i][n-1])
return binarySearch(mat, i, 0, n-1, target);
}
return false;
}
}

25. Head a sorted linked list by removing all duplicates to make sure each entry only appears once. Return the linked list in order.

By locating the nodes that contain the duplicate value, we can use the two-pointer method to resolve this issue. Identifying the node with duplicate values is simple because the lists are already sorted. The code for this problem will therefore be -

class Solution {
public ListNode deleteDuplicates(ListNode head) {
// if LL is empty or contains only 1 element then return LL.
if(head==null || head.next==null) {
return head;
}
// creating a dummy Head for traversing the LinkedList.
ListNode node = head;
while(node.next!=null) {
if(node.val!=node.next.val) {
// if value of current node is same as value of next node then
// traverse the node forward.
node = node.next;
} else {
// if value of current node is same as value of next node then 
//connect current with next to next node.
node.next = node.next.next;
}
}
return head;
}
}

26. Two integers, m, and n, as well as the initial 0-indexed 1-dimensional integer array, are given to you. You must use every component from the original to produce a 2D array with m rows and n columns.

The integer indices in the initial array range from 0 to n-1 (inclusive). The integer indices from n to 2 * n - 1 are used to build the second row of the 2D array (inclusive).

Making a 2D array with the specified row and column sizes can be straightforward. The element can then be fed to the 2D array based on the row and column by simply starting to traverse the 1D array.

class Solution {
public int[][] construct2DArray(int[] arr, int r, int c) {
//IF THE NUMBER OF ELEMENTS IN THE ARRAY IS LESS OR GREATER
//WE RETURN EMPTY ARRAY
if(r*c != arr.length){return new int[0][0];}
//2D ARRAY
int ans[][] = new int[r][c];
//COUNTER
int count = 0;
//2 FOR LOOPS FOR ADDING THE ELEMENTS IN 2D ARRAY
for(int i= 0;i <r; i++)
{
for(int j =0; j<c; j++)
{
ans[i][j] = arr[count];
count++;
}
}
//RETURNING 2D ARRAY 
return ans;
}
}

27. Get the BST status of a binary tree given its root. Next, decide if it is a legitimate BST. A binary search tree (BST) is a tree in which both subtrees are binary search trees, and each node's subtrees are likewise BSTs.

This issue is readily resolved with the aid of recursion. We only need to understand that each subtree needs to be a binary search tree. Therefore, this is the recursive method to the solution.

class Solution {
//private method that validates the tree by the values of root and sub roots
private boolean solution(TreeNode root, long left, long right){
//Base case to determine if we reach the leaf of the
//tree and found no error. Then the part is the valid BST
if(root == null)
return true;        
//Comparing the value of the subtrees that all values to 
//its sub tree must fulfill the condition of validity. 
if(!(root.val < right && root.val > left))
return false;        
//Recursively validating it's right subtree and left subtree.
return ((solution(root.left, left, root.val)) &&
(solution(root.right, root.val, right)));                
}
//Method that validates and returns true if it's valid. 
public boolean isValidBST(TreeNode root) {
//Calling private helper method to validate.
return solution(root, Long.MIN_VALUE, Long.MAX_VALUE);
}
}

28. Return the missing number from an array of n unique values in the range [0, n].

For instance, [0,6,8,5,1,2,3,4] 7 is the missing number.

A hash table containing the numbers 0 to n can help us address this issue. And if any numbers remain after marking, we will return those numbers. But this requires more room. In order to maximize this, we can use mathematics to determine the actual sum that must exist from an array of numbers (1 - n). The code solution will therefore be -

//Method that returns the missing number
public int missingNumber(int[] nums) {
int sumArray = 0;
int n = nums.length;
//calculating sum of number from array
for(int i = 0; i<n; i++)
sumArray += nums[i];
//The actual sum
int ActualSum = (n*n + n)/2;
// Returning the difference, the will be the missing number
return ActualSum - sumArray;
}

29. Java HashMap Implementation

For storing map entries, HashMap employs its static inner class Node. As a result, each node in the hashMap is an entry. Fundamentally, HashMap uses a hashCode for the key Object, and the hash function utilizes this hashCode to determine the index of the bucket to which the new object should be appended.

30. Java's HashMap and HashTable differences.

HashMap and Hashtable are two Java data structures that differ in a number of ways: HashMap is unsynchronized and performs better than synchronized objects generally, but Hashtable is synchronized and better for non-threaded workloads. Hashtables do not permit empty keys or empty values.

Virtusa Leadership Principles 

Innovative engineering is used by Virtusa Corporation, a global provider of digital business strategy, digital engineering, and information technology (IT) services and solutions, to assist clients to transform industries and create new value. The banking, financial services, insurance, healthcare, communications, media, entertainment, travel, manufacturing, and technology industries are all served by Virtusa.

With cutting-edge solutions and services that use digital labor to produce operational efficiency, future-proof operational and IT platforms and rationalization and modernization of IT application architecture, Virtusa assists clients in expanding their businesses. This is accomplished through a special strategy that combines profound contextual understanding, empowered agile teams, and measurably improved engineering to develop comprehensive solutions that propel the company ahead with unmatched speed and are supported by a culture of cooperative disruption.

Virtusa assists clients in implementing effective end-to-end digital business transformation efforts by combining digital strategy, digital engineering, business implementation, and IT platform modernization services.

  • Passion: to motivate our international employees to produce exceptional results.
  • Innovation: Reimagine better business outcomes for our clients by using intellectual curiosity.
  • Respect: Respect diversity, preserve the environment and treat everyone with respect. 

Interview Preparation Tips

  • The interviewer at Virtusa mostly observes your level of attention: As a result, pay close attention during the interview. Make eye contact with each interviewer as they speak to you since this will help the interviewer see that you are paying attention. They will see that you are paying attention to them and are interested in what they have to say. Pay close attention to each question and provide thoughtful responses.
  • Prepare from Resume: Ensure that the material on your resume is well-prepared. Because the interviewer may enquire about any matter relevant to those covered in your resume, you must not lie on your resume. Programming languages, web technology, topics of interest, etc., are a few examples.
  • Project: The Virtusa interviewer will talk about your project for roughly 15 to 20 minutes. Therefore make sure you can respond to this question adequately. If you created the project yourself, you will find responding quite simple.
  • Java: Active Programming language ion virtusa is mostly on Java. Therefore, it's good if you are skilled in Java. Otherwise, make the coffee. The interviewer will also probe into Java. It's not necessarily direct, but it takes the shape of notions from object-oriented programs, such as Dynamic Method DIspatch in OOPs, which can only be satisfactorily addressed in Java.
  • Develop Your Computer Basics: It's preferable that you be familiar with core computing concepts. Which operating system you use can be one of the interviewer's questions. What is the most recent release of this? Also, the interviewer may occasionally ask you to describe how to install a new operating system. any more inquiries of this nature.
  • Prepare for Scenario-based Questions: The interviewer may also ask you questions that require you to provide answers based on hypothetical situations. With these questions, the interviewer gauges your capacity for critical thought as well as your problem-solving skills.

Virtusa Frequently Asked Questions

1. Is the Virtusa interview challenging?

Clearing the Virtusa interview is not difficult. Nonetheless, if you haven't prepared properly, passing will undoubtedly be challenging. Usually, the interviewer can tell how confident you are. For the critical subjects specified in the areas mentioned above, be well-prepared. Your project is the other. How well you're prepared to respond to inquiries about it

2. How do I prepare for a Virtusa interview?

  • Understand every aspect of your projects because you can receive many inquiries regarding them.
  • Discover all of the fundamental Java concepts.

Prepare all of the database's fundamental questions.

The candidate ought to be familiar with the fundamentals of the SDLC Model.

3. What are the technical questions asked in Virtusa interview?

The interviewer begins by asking basic questions on the foundational concepts of computers before moving on to deeper questions about Object-Oriented programming. Also, the interviewer will quiz you on Java's fundamentals. When thoroughly studied, the question will be of medium difficulty and be simple to answer. Also, the interviewer will enquire about the projects you worked on. The project discussion is crucial since Virtusa employs software engineers with some software development knowledge.

4. Why choose Virtusa company?

You need to consider all of the potential best responses to this question. The interviewer frequently uses these questions to gauge how interested you are in the company. They want a unique response from you, not just one that you can find online. Try to learn everything you can about the company's work culture for your chosen profile, then answer this question with curiosity so that it shows the interviewer that you are eager to work for the organization.

5. What are the 5 hardest interview questions?

The most difficult interview questions 

  • What is your biggest flaw?
  • Why should we employ you?
  • What was it about your previous position that you didn't like?
  • Why do you desire this position?
  • How do you resolve a disagreement with a coworker?

6. Does Virtusa pay well?

From roughly $21,133 per year for an operations analyst to $20,000 per year for a senior architect, that is the range of the average Virtusa wage. The typical Virtusa compensation per month ranges from around 17,954 for a recruiter to 46,098 for a Net developer.

7. How many rounds are in Virtusa?

The on-campus and off-campus Virtusa recruitment process consists of 4 rounds.

Conclusion

You are now well-prepared for your interview thanks to the Virtusa interview questions that have been provided in this post. We hope your Virtusa interview goes well.

We also advise enrolling in the Core Java Training from Mindmajix in order to become adept in technical abilities and develop your fundamental soft skills. These courses provide comprehensive knowledge of software development and testing tools like Protractor, Node.js, Angular, JavaScript, and Node. 

Please post any questions or comments you may have in the space provided below. Our team will respond to you with the answers as soon as we can.

Job Support Program

Online Work Support for your on-job roles.

jobservice

Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:

  • Pay Per Hour
  • Pay Per Week
  • Monthly
Learn MoreGet Job Support
Course Schedule
NameDates
Core Java TrainingNov 19 to Dec 04View Details
Core Java TrainingNov 23 to Dec 08View Details
Core Java TrainingNov 26 to Dec 11View Details
Core Java TrainingNov 30 to Dec 15View Details
Last updated: 07 Oct 2024
About Author

 

Madhuri is a Senior Content Creator at MindMajix. She has written about a range of different topics on various technologies, which include, Splunk, Tensorflow, Selenium, and CEH. She spends most of her time researching on technology, and startups. Connect with her via LinkedIn and Twitter .

read less
  1. Share:
Java Articles