0% found this document useful (0 votes)
17 views8 pages

Software Engineer Test 1 Solution

The document contains a test for a Software Engineer position at Zypp Electric, featuring multiple-choice questions on Java programming concepts and SQL queries. It includes questions about class inheritance, exception handling, and SQL functions, along with code examples for practical understanding. The test is designed to assess the candidate's knowledge and skills in software engineering within a 45-minute timeframe.

Uploaded by

karchiii151
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views8 pages

Software Engineer Test 1 Solution

The document contains a test for a Software Engineer position at Zypp Electric, featuring multiple-choice questions on Java programming concepts and SQL queries. It includes questions about class inheritance, exception handling, and SQL functions, along with code examples for practical understanding. The test is designed to assess the candidate's knowledge and skills in software engineering within a 45-minute timeframe.

Uploaded by

karchiii151
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Zypp Electric

Software Engineer Test 1 - Time: - 45 Mins

NAME: - Chandrabhan singh_ Reg.No: -12018242 Date:15-02-2-24__

Follow any specific instructions provided with each question.

1. Which of the following is a superclass of every class in Java?


a) ArrayList
b) Abstract class
c) Object class
d) String

Ans :-(c) Object class

2. Which one of the following is not an access modifier?


a) Protected
b) Void
c) Public
d) Private

Ans :-(b) Void

3. Which of these is the correct way of inheriting class A by class B?


a) class B + class A {}
b) class B inherits class A {}
c) class B extends A {}
d) class B extends class A {}

Ans:-(c) class B extends A {}

4. Which of these keywords are used for generating an exception manually?


a) try
b) catch
c) throw
d) check

Ans: -(c)throw

5. What happens if we put a key object in a HashMap which exists?


a) The new object replaces the older object
b) The new object is discarded
c) The old object is removed from the map
d) It throws an exception as the key already exists in the map

Ans:-(a) The new object replaces the older object

6. What is the process of defining a method in a subclass having same name &
type signature as a method in its superclass?
a) Method overloading
b) Method overriding
c) Method hiding
d) None of the mentioned

Ans:-(b) Method Overriding

7. What is the use of final keyword in Java?


a) When a class is made final, a subclass of it cannot be created
b) When a method is final, it cannot be overridden.
c) When a variable is final, it can be assigned value only once.
d) All of the above

Ans:-(d) All of the above

8. What is true about a break?


a) Break stops the execution of entire program
b) Break halts the execution and forces the control out of the loop
c) Break forces the control out of the loop and starts the execution of next iteration
d) Break halts the execution of the loop for certain time frame

Ans:-(b) Break halts the execution and forces the control out of the loop

9. How To Remove Duplicate Elements From ArrayList In Java?


Input: [1,2,4,2,4,5]
Output: [1,2,4,5]

Code: -

import java.util.ArrayList;
import java.util.LinkedHashSet;

public class Main {


public static void main (String[] args) {
ArrayList<Integer> list = new ArrayList<>();
list.add (1);
list.add(2);
list.add(4);
list.add(2);
list.add(4);
list.add(5);

LinkedHashSet<Integer> hashSet = new LinkedHashSet<>(list);


ArrayList<Integer> listWithoutDuplicates = new ArrayList<>(hashSet);
System.out.println(listWithoutDuplicates);
}
}

10. Given a sorted array of distinct integers and a target value, return the index if the
target is found.
If not, return the index where it would be if it were inserted in order. You must write
an algorithm with O(log n) runtime complexity.
Input: nums = [1,3,5,6], target = 5
Output: 2

Code: -
public class Main {
public static void main(String[] args) {
int[] nums = {1, 3, 5, 6};
int target = 5;
System.out.println(searchInsert(nums, target));
}

public static int searchInsert(int[] nums, int target) {


int left = 0, right = nums.length - 1;
while (left <= right) {
int mid = left + (right - left) / 2;
if (nums[mid] == target) {
return mid;
} else if (nums[mid] < target) {
left = mid + 1;
} else {
right = mid - 1;
}
}
return left;
}
}
SQL Questions
Estimated Time  45 Minutes

 Which MySQL function would you use to concatenate strings from multiple rows into
a single string?

GROUP_CONCAT
 Which SQL keyword is used to define a window function?

 In a SQL query containing multiple clauses (e.g., SELECT, FROM, WHERE, JOIN, GROUP
BY, ORDER BY, what is the typical execution order?

FROM/JOIN, WHERE, GROUP BY, HAVING, SELECT , ORDER BY,


LIMIT/OFFSET

SELECT, FROM/JOIN, WHERE, GROUP BY, HAVING ORDER BY,


LIMIT/OFFSET

SELECT, FROM/JOIN, WHERE, ORDER BY, GROUP BY, HAVING, LIMIT/OFFSET

 In MySQL, which of the following commands can be used to remove an index from a
table?

DROP INDEX

DELETE INDEX

SQL Questions
 What is the primary purpose of the CASE WHEN statement in SQL?

To define conditions for filtering rows in a WHERE clause.

To specify the order in which columns should be sorted in a result set.

To perform conditional logic and return different values based on specified


conditions.

To join multiple tables based on common columns.

 In MySQL, which statement is used to add an index to an existing table?

 Which JOIN type in MySQL is suitable for combining rows from two tables even if
there is no match found in the other table?

 In SQL, what is the typical syntax for using the LAG function?

SQL Questions
 Question  1:
Consider the following scenario where you have a table named
"employees" in a MySQL database. The table has the following structure:

Now, imagine you frequently execute the following query to retrieve employees
earning a salary greater than a specified amount within a particular department:

Based on the provided query, which column or columns would you recommend
indexing on the "employees" table to optimize the query's performance? Write the
index structure and explain your reasoning.

 Question  2

The ideal time between when a customer places an order and when the order is
delivered is below or equal to 45 minutes.
You have been tasked with evaluating delivery driver performance by calculating the
average order value for each delivery driver who has delivered at least once within
this 45-minute period.

SQL Questions
Your output should contain the driver ID along with their corresponding average
order value. Table: Delivery_details Create Table Query

CREATE TABLE orders (


customer_placed_order_datetime DATETIME,
placed_order_with_restaurant_datetime DATETIME,
driver_at_restaurant_datetime DATETIME,
delivered_to_consumer_datetime DATETIME,

SQL Questions

You might also like