Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
19 views10 pages

ZYPP

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 10

NAME:- SHRESTHI SINGH

Reg.No:-12014212
Date:- 15 FEB

Software Engineer Test2

Follow any specific instructions provided with each question.

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

a) Array List

b) Abstract class

c) Object class

d) String

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

a) Protected

b) Void

c) Public

d) Private

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 {}

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


a) try

b) catch

c) throw

d) check

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

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

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

a) When a class is made final, a subclass of it can not be created

b) When a method is final, it can not be overridden.

c) When a variable is final, it can be assigned value only once.

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
9. How To Remove Duplicate Elements From ArrayList In Java? Input : [1,2,4,2,4,5] Output :
[1,2,4,5]

Sol:

import java.util.ArrayList;

public class HelloWorld {

public static void main(String[] args) {

ArrayList<Integer> input = new ArrayList<>();

input.add(1);

input.add(2);

input.add(4);

input.add(2);

input.add(4);

input.add(5);

ArrayList<Integer> output = removeDuplicates(input);

System.out.println(" Output is: " + output);

public static ArrayList<Integer> removeDuplicates(ArrayList<Integer> input) {

ArrayList<Integer> output = new ArrayList<>();

for (Integer element : input) {

if (!output.contains(element)) {

output.add(element);

return output;

}
}

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

#include <iostream>

int search(int nums[], int length, int key) {

int left = 0;

int right = length;

while (left < right) {

int mid = left + (right - left) / 2;

if (nums[mid] < key) {

left = mid + 1;

} else {

right = mid;

return left;

int main() {

int nums[] = {1, 3, 5, 6};

int length = 4;

int key = 5;

int result = search(nums, length, key);

std::cout << "Target value is " << result << std::endl;

return 0;
Software Engineer Test2

SQL Questions

1.Which MySQL function would you use to concatenate strings from multiple rows into a
single string?
1. CONCAT_WS
2. GROUP_CONCAT
3. CONCAT
4. STRING_CONCAT

2. Which SQL keyword is used to define a window function?


1. WINDOW
2. OVER
3. PARTITION
4. WITH

3. In a SQL query containing multiple clauses (e.g., SELECT, FROM, WHERE, JOIN,
GROUP BY, ORDER BY), what is the typical execution order?
1. FROM/JOIN, WHERE, GROUP BY, HAVING, SELECT, ORDER BY,
LIMIT/OFFSET
2. SELECT, FROM/JOIN, WHERE, GROUP BY, HAVING ORDER BY,
LIMIT/OFFSET
3. SELECT, FROM/JOIN, WHERE, ORDER BY, GROUP BY, HAVING,
LIMIT/OFFSET
4. WHERE, FROM, GROUP BY, HAVING, ORDER BY, SELECT,
LIMIT/OFFSET

4.In MySQL, which of the following commands can be used to remove an index from a
table?
1. DROP INDEX
2. DELETE INDEX
3. REMOVE INDEX
4. ERASE INDEX
5. What is the primary purpose of the CASE WHEN statement in SQL?
1. To define conditions for filtering rows in a WHERE clause.
2. To specify the order in which columns should be sorted in a result set.
3. To perform conditional logic and return different values based on specified
conditions.
4. To join multiple tables based on common columns.

6. In MySQL, which statement is used to add an index to an existing table?


1. ALTER INDEX
2. MODIFY INDEX
3. ADD INDEX
4. CREATE INDEX

7. Which JOIN type in MySQL is suitable for combining rows from two tables even if there
is no match found in the other table?
1. INNER JOIN
2. LEFT JOIN
3. RIGHT JOIN
4. FULL OUTER JOIN

8. In SQL, what is the typical syntax for using the LAG function?
1. LAG(column_name)
2. LAG(column_name, n)
3. LAG(n, column_name)
4. LAG()

9. Question 1

Consider the following scenario where you :

CREATE TABLE employees (


emp_id INT PRIMARY KEY,
emp_name VARCHAR(50),
department_id INT,
salary DECIMAL(10, 2),
hire_date DATE );

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

SELECT emp_name,
salary FROM employees WHERE department_id = ? AND salary > ?
ORDER BY hire_date DESC;

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.

Sol:

As we know the query CREATE INDEX is used to create indexes in tables and those indices are used to
retrieve data very quickly and we are asked to optimize the query’s performance we will make use of
it to speed up searches/queries. Hence, the structure would be:

CREATE INDEX departmentSI ON employees (department_id, salary);

10. 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. 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,

driver_id INT,

restaurant_id INT,

consumer_id INT,

is_new BOOLEAN,

delivery_region VARCHAR(255),

is_asap BOOLEAN,

order_total FLOAT,

discount_amount FLOAT,

tip_amount FLOAT,

refunded_amount FLOAT

);

Sol:

SELECT driver_id,

AVG (order_total) AS average_order_value

FROM orders

WHERE TIMESTAMPDIFF(MINUTE, placed_order_with_restaurant_datetime,

delivered_to_consumer_datetime) <= 45

GROUP BY driver_id;

We will select Driver_id then calculate average order value to calculate the order which was
within the given timeframe. We will then group them for results.
IoT Questions
● Which communication protocol is commonly used for lightweight messaging in IoT?

A) TCP

B) HTTP

C) MQTT

D) FTP

● What is a telematics device primarily used for?

a) Remote vehicle diagnostics

b) GPS navigation

c) In-car entertainment

d) Tire pressure monitoring

● What technology is commonly used for wireless communication in telematics devices?

a) Bluetooth

b) Zigbee

c) Wi-Fi

d) Cellular

● What is the main purpose of the GPS receiver in a telematics device?

a) Monitor engine performance

b) Control vehicle temperature

c) Track vehicle location

d) Adjust tire pressure

● What does CAN stand for in the context of telematics devices?

a) Controlled Area Network

b) Cellular Access Network

c) Controller Area Network


d) Centralized Area Network

● What is the purpose of the accelerometer in a telematics device?

a) Measure vehicle speed

b) Detect harsh driving events

c) Monitor fuel consumption

d) Control vehicle lighting

● How do telematics devices contribute to fleet management?

a) Increased fuel consumption

b) Reduced vehicle downtime

c) Higher maintenance costs

d) Decreased driver safety

● What security feature is commonly offered by advanced telematics devices?

a) Real-time vehicle tracking

b) Driver behavior monitoring

c) Remote engine immobilization

d) In-car entertainment

● What regulatory compliance standards are telematics devices typically required to meet?

a) ISO 9001

b) OBD-II

c) FCC

d) None of the above

● How do telematics devices facilitate remote vehicle diagnostics?

a) By providing real-time alerts for maintenance issues

b) By controlling vehicle temperature settings

c) By monitoring tire pressure

d) By adjusting engine performance

You might also like