Add office photos
Engaged Employer

Oracle

3.7
based on 5k Reviews
Filter interviews by

100+ Diligenta 2 Interview Questions and Answers

Updated 2 Oct 2024
Popular Designations

Q1. Puzzle: – Two persons X and Y are sitting side by side with a coin in each’s hand. The game is to simultaneously flip the coin till anyone wins. Player X will win if he gets a consecutive HEAD, TAIL however Y w...

read more
Ans.

The game is not fair.

  • Player X has a higher chance of winning as they only need to get a consecutive HEAD, TAIL.

  • Player Y needs to get a consecutive HEAD, HEAD which is less likely to occur.

  • The probability of Player X winning is higher than Player Y winning.

Add your answer

Q2. In a bag you have 20 black balls and 16 red balls.When you take out 2 black balls you take another white ball.If you take 2 white balls then you take out 1 black ball and if balls are of different color you tak...

read more
Ans.

The last ball that will be left is black.

  • When you take out 2 black balls, you take another white ball.

  • If you take 2 white balls, you take out 1 black ball.

  • If balls are of different color, you take out another black ball.

  • Since there are more black balls initially, the last ball will be black.

Add your answer

Q3. Design a website similar to bookmyshow.com for booking cinema tickets but it must be for a single location only which can have multiple theatres in it. In this he wanted me to design a basic rough GUI, relevant...

read more
Ans.

Design a website similar to bookmyshow.com for booking cinema tickets for a single location with multiple theatres.

  • Design a user-friendly GUI with options for advance booking, user login, user registration, movie rating, and saving card details.

  • Create relevant database tables to store information about movies, theatres, bookings, user details, and card details.

  • Link the GUI to the database to enable data flow and retrieval.

  • Implement features like advance booking, where users c...read more

Add your answer

Q4. Provided a string a character and a count, you have to print the string after the specified character has occurred count number of times. Ex: String: “This is demo string” Character: ‘i’ Count: 3 Output: “ng” H...

read more
Ans.

The program prints the substring after a specified character has occurred a certain number of times in a given string.

  • Iterate through the string to find the specified character.

  • Keep track of the count of occurrences of the character.

  • Once the count reaches the specified count, extract the substring after that position.

  • Handle corner cases such as when the character is not in the string or when it doesn't occur the specified number of times.

Add your answer
Discover Diligenta 2 interview dos and don'ts from real experiences
Q5. Partition Equal Subset Sum

You are given an array 'ARR' of 'N' positive integers. Your task is to find if we can partition the given array into two subsets such that the sum of elements in both subsets is equal....read more

View 4 more answers

Q6. There are five glasses that are kept upside down.At a time you are bound to turn four glasses.Give minimum number of times in which you can turn back all the glasses so that now none among them are upside down

Ans.

Minimum number of times to turn all glasses upside down when 4 can be turned at a time.

  • Turn over any four glasses, leaving one untouched.

  • Repeat the above step until only one glass is left upside down.

  • Finally, turn over the last glass to complete the task.

  • Minimum number of turns required is 3.

Add your answer
Are these interview questions helpful?
Q7. Search in a row wise and column wise sorted matrix

You are given an N * N matrix of integers where each row and each column is sorted in increasing order. You are given a target integer 'X'. Find the position of...read more

View 3 more answers

Q8. Code: – Given the value of a starting position and an ending position, you have to reach from start to end in a linear way, and you can move either to position immediate right to current position or two step ri...

read more
Ans.

Print all possible paths from start to end in a linear way, moving either one or two steps right.

  • Use dynamic programming to solve the problem

  • Create a 2D array to store the number of paths to each position

  • Start from the end position and work backwards

  • At each position, calculate the number of paths by summing the number of paths from the next two positions

  • Print all the paths by backtracking from the start position

Add your answer
Share interview questions and help millions of jobseekers 🌟
Q9. Reverse Words in a String

You are given a string of length N. You need to reverse the string word by word. There can be multiple spaces between two words and there can be leading or trailing spaces but in the ou...read more

View 2 more answers
Q10. Largest subarray with equal number of 0s and 1s

You are given an array consisting of 0s and 1s. You need to find the length of the largest subarray with an equal number of 0s and 1s.

For example:

If the given ar...read more
View 3 more answers
Q11. Minimum Number of Platform Needed

You are given the arrival and departure times of N trains at a railway station in a day. You need to find the minimum of platforms required for the railway station such that no ...read more

View 2 more answers
Q12. Pascal case of a given sentence

Given a string “STR”, you need to remove spaces from the string “STR” and rewrite in the Pascal case. Your task is to return the string “STR”.

In the Pascal case writing style we ...read more

Add your answer

Q13. Write a code for inserting two numbers in a text file given n2>n1 and the next entry should not be overlapping like if first was 4,6 next can't be 5,7.the second n1 has to be greater than first n2

Ans.

The code inserts two numbers in a text file, ensuring that the second number is greater than the first and there is no overlap between entries.

  • Read the existing entries from the text file

  • Check if the new numbers satisfy the conditions

  • If conditions are met, insert the new numbers into the file

  • Otherwise, display an error message

Add your answer
Q14. Valid Parenthesis

You're given string ‘STR’ consisting solely of “{“, “}”, “(“, “)”, “[“ and “]” . Determine whether the parentheses are balanced.

Input Format:
The first line contains an Integer 'T' which denot...read more
Add your answer
Q15. DBMS Questions

1. He asked me to write an SQL query, “Given a table with duplicate rows, remove duplicate rows from table”. I was not able to solve this question.
2. He asked me to write an SQL query, “Given empl...read more

Add your answer
Q16. Sum Tree

For a given binary tree, convert it to its sum tree. That is, replace every node data with sum of its immediate children, keeping leaf nodes 0. Finally, return its preorder.

For example:
The input for t...read more
Add your answer
Q17. Inplace rotate matrix 90 degree

You are given a square matrix of non-negative integers of size 'N x N'. Your task is to rotate that array by 90 degrees in an anti-clockwise direction without using any extra spac...read more

View 2 more answers
Q18. Colour the Graph

You are given a graph with 'N' vertices numbered from '1' to 'N' and 'M' edges. You have to colour this graph in two different colours, say blue and red such that no two vertices connected by an...read more

Add your answer
Q19. Convert a given number to words

Given an integer number ‘num’. Your task is to convert ‘num’ into a word.

Suppose the given number ‘num’ is ‘9823’ then you have to return a string “nine thousand eight hundred tw...read more

View 2 more answers

Q20. Write code to find the middle element of a linked list

Ans.

Code to find the middle element of a linked list

  • Traverse the linked list with two pointers, one moving twice as fast as the other

  • When the fast pointer reaches the end, the slow pointer will be at the middle element

  • If the linked list has even number of elements, return the second middle element

Add your answer

Q21. Write a code to count the number of times '1' occurs from 1 to 999999

Ans.

Code to count the number of times '1' occurs from 1 to 999999

  • Loop through all numbers from 1 to 999999

  • Convert each number to a string and count the number of '1's in it

  • Add the count to a running total

  • Return the total count

Add your answer

Q22. Given a matrix.Write a code to print the transpose of the matrix

Ans.

The code prints the transpose of a given matrix.

  • Iterate through each row and column of the matrix.

  • Swap the elements at the current row and column with the elements at the current column and row.

  • Print the transposed matrix.

Add your answer

Q23. Puzzle: Gi1ven 4 coins, arrange then to make maximum numbers of triangle of the figure

Ans.

Arrange 4 coins to make maximum number of triangles

  • Place 3 coins in a triangle formation and the fourth coin in the center to form 4 triangles

  • Place 2 coins on top of each other and the other 2 coins on either side to form 2 triangles

  • Place 2 coins in a line and the other 2 coins on either side to form 2 triangles

Add your answer

Q24. Puzzle: Given 10 coins, arrange them such that we get 4 different rows each containing 4 coins

Ans.

Arrange 10 coins in 4 rows of 4 coins each.

  • Place 4 coins in a row and keep the remaining 6 aside.

  • Place 3 coins from the remaining 6 in the next row and keep the remaining 3 aside.

  • Place 2 coins from the remaining 3 in the third row and keep the remaining 1 aside.

  • Place the last coin in the fourth row along with the remaining 1 coin from step 3.

  • The final arrangement will have 4 rows with 4 coins each.

Add your answer
Q25. Convert Into Words

Let's say I give you a number 1,53,345 (I don't remember exactly). Write a program that will take the above number as input array and give output as "One Lakh Fifty-Three Thousand Three Hundre...read more

View 3 more answers
Q26. OOPS Questions

What is a virtual function? Give an example.

What is encapsulation? What is polymorphism?

Add your answer

Q27. Explain multitasking and multiprogramming

Ans.

Multitasking is the ability of an operating system to run multiple tasks concurrently while multiprogramming is the ability to run multiple programs concurrently.

  • Multitasking allows multiple tasks to run concurrently on a single processor system.

  • Multiprogramming allows multiple programs to run concurrently on a single processor system.

  • Multitasking is achieved through time-sharing, where the processor switches between tasks at a very high speed.

  • Multiprogramming is achieved thr...read more

Add your answer

Q28. What is the difference between a micro controller and a micro processor?

Ans.

Microcontroller is a self-contained system with memory, peripherals and processor, while microprocessor only has a processor.

  • Microcontroller has on-chip memory and peripherals, while microprocessor requires external memory and peripherals.

  • Microcontroller is used in embedded systems, while microprocessor is used in general-purpose computing.

  • Examples of microcontrollers include Arduino, PIC, and AVR, while examples of microprocessors include Intel Pentium, AMD Ryzen, and ARM Co...read more

Add your answer
Q29. SQL Queries

SQL query - Top 2 users in a table - do it using subquery, views, and joins.
SQL query - Nested query using joins.

Add your answer
Q30. Stack basics

If I want to implement a stack then what should the value of the pointer (top of stack) in case of an empty stack? 0 or -1?

Add your answer

Q31. Can an array have elements of different data types?

Ans.

Yes, an array can have elements of different data types.

  • An array can have elements of different data types, but it's not recommended.

  • It can make the code harder to read and maintain.

  • For example, an array can have both strings and numbers: ['apple', 5, 'banana']

View 1 answer

Q32. Design circular doubly linked list with all operations.

Ans.

Circular doubly linked list is a data structure where each node has a reference to both the next and previous nodes, forming a circular loop.

  • Create a Node class with data, next, and prev pointers

  • Implement operations like insert, delete, search, and display

  • Ensure the last node's next pointer points to the first node and the first node's prev pointer points to the last node

Add your answer

Q33. Different types of searching and sorting algo discussion.

Ans.

Searching and sorting algorithms are essential in programming for efficiently organizing and retrieving data.

  • Searching algorithms: linear search, binary search, depth-first search, breadth-first search

  • Sorting algorithms: bubble sort, selection sort, insertion sort, merge sort, quick sort

  • Examples: Searching for a specific item in a list, sorting a list of numbers in ascending order

Add your answer
Q34. Excel Column Number

You have been given a column title as appears in an Excel sheet, return its corresponding column number.

View 3 more answers
Q35. Degree between an hour hand and a minute hand

Find the degree between an hour hand and a minute hand? Gave me a pen and paper to come up with the answer (it was an equation).

Add your answer

Q36. Modified Balanced Parentheses where a character can be matched with any other character, i.e. / with &, ! with ? and so on.

Ans.

Modified Balanced Parentheses where characters can be matched with any other character.

  • Use a stack to keep track of opening characters

  • When encountering a closing character, check if it matches the top of the stack

  • If it matches, pop from the stack, else return false

  • Continue until end of string, return true if stack is empty

Add your answer
Q37. Number and Digits

You are given a positive number ‘N.’ You need to find all the numbers such that the sum of digits of those numbers to the number itself is equal to ‘N.’

For example:
You are given ‘N’ as 21, th...read more
View 3 more answers

Q38. Given an array of strings, print all the possible combinations of strings created by picking one character from each string of the array. The individual strings do not contain any duplicates. Ex: {ABC, DE} Ans ...

read more
Ans.

Print all possible combinations of strings by picking one character from each string in the array.

  • Iterate through each character of the first string and combine it with each character of the second string.

  • Repeat the process for all strings in the array to get all possible combinations.

  • Use nested loops to generate combinations efficiently.

Add your answer
Q39. Find The Repeating And Missing Number

You are given an array 'nums' consisting of first N positive integers. But from the N integers, one of the integers occurs twice in the array, and one of the integers is mis...read more

View 5 more answers

Q40. What is a linked list ? What are its uses?

Ans.

A linked list is a linear data structure where each element is a separate object linked together by pointers.

  • Linked list is used to implement stacks, queues, and hash tables.

  • It is used in computer memory allocation.

  • It is used in image processing to represent pixels.

  • It is used in music player to create a playlist.

  • It is used in web browsers to store the history of visited web pages.

View 1 answer
Q41. What is encapsulation? What is polymorphism?
Add your answer

Q42. What are data structures?

Ans.

Data structures are ways of organizing and storing data in a computer so that it can be accessed and used efficiently.

  • Data structures can be linear or non-linear

  • Examples of linear data structures include arrays, linked lists, and stacks

  • Examples of non-linear data structures include trees and graphs

  • Choosing the right data structure is important for optimizing performance and memory usage

View 2 more answers
Q43. SQL Question

Write SQL query to get Nth highest salary

Add your answer
Q44. What is a virtual function? Give an example.
Add your answer

Q45. Given a date in string format, write a java program to return the date n days after the given date. Solve the question without using DateTimeFormatter or any similar Date parsing libraries.

Ans.

Java program to calculate date n days after given date without using Date parsing libraries.

  • Parse the input date string to extract day, month, and year components.

  • Calculate the total number of days represented by the input date.

  • Add the specified number of days to the total days calculated.

  • Convert the final total days back to day, month, and year components to get the new date.

Add your answer
Q46. Check If One String Is A Rotation Of Another String

You are given two Strings 'P' and 'Q' of equal length. Your task is to check whether String 'P' can be converted into String 'Q' by cyclically rotating it to t...read more

View 2 more answers
Q47. Merge K Sorted Arrays

You have been given ‘K’ different arrays/lists, which are sorted individually (in ascending order). You need to merge all the given arrays/list such that the output array/list should be sor...read more

View 3 more answers

Q48. Largest element in window size K

Ans.

Find the largest element in a window of size K in an array.

  • Iterate through the array and maintain a deque to store the indices of elements in decreasing order.

  • Remove indices from the front of the deque that are outside the current window.

  • The front of the deque will always have the index of the largest element in the current window.

Add your answer

Q49. Tell me about the OS your phone uses? What are the other phone operating systems available in the market

Ans.

My phone uses iOS. Other phone operating systems available in the market are Android, Windows, and Blackberry OS.

  • iOS is developed by Apple and is exclusive to iPhones and iPads.

  • Android is developed by Google and is used by various phone manufacturers such as Samsung, LG, and HTC.

  • Windows is developed by Microsoft and is used by Nokia and other phone manufacturers.

  • Blackberry OS is developed by Blackberry and is exclusive to Blackberry phones.

View 1 answer

Q50. Explain about the transaction that happen in a bank

Ans.

Transactions in a bank involve the movement of funds between accounts or the exchange of currency.

  • Transactions can be initiated by customers or by the bank itself

  • Common types of transactions include deposits, withdrawals, transfers, and loans

  • Transactions are recorded in the bank's ledger and may be subject to fees or interest

  • Electronic transactions have become increasingly popular, such as online banking and mobile payments

Add your answer

Q51. Print all combinations of numbers in an array which sum up to a number k. Ex : Arr={3,1,4,5} k=5 Ans : {{1,4},{5}}

Ans.

Use backtracking to find all combinations of numbers in an array that sum up to a given number.

  • Start by sorting the array in non-decreasing order to easily identify combinations.

  • Use backtracking to recursively find all combinations that sum up to the target number.

  • Keep track of the current combination and the remaining sum as you traverse the array.

  • Add the current combination to the result when the sum equals the target number.

Add your answer
Q52. Preorder traversal to BST

You have been given an array/list 'PREORDER' representing the preorder traversal of a BST with 'N' nodes. All the elements in the given array have distinct values.

Your task is to const...read more

View 2 more answers
Q53. Subarray With Given Sum

Given an array ARR of N integers and an integer S. The task is to find whether there exists a subarray(positive length) of the given array such that the sum of elements of the subarray eq...read more

View 2 more answers
Q54. Check if number is Binary

Given a string of integers ‘bin’. Return 'true' if the string represents a valid binary number, else return 'false'. A binary number is a number that has only 0 or 1 in it.

Input Format...read more
View 3 more answers
Q55. Rearrange The Array

You are given an array/list 'NUM' of integers. You are supposed to rearrange the elements of the given 'NUM' so that after rearranging the given array/list there are no two adjacent elements ...read more

View 2 more answers

Q56. Given array contain duplicate elements need to remove duplicates and after deletion oreder of remaining element should remain same..

Ans.

Remove duplicates from array of strings while maintaining original order.

  • Iterate through the array and use a Set to keep track of unique elements.

  • Add elements to a new array only if they are not already in the Set.

Add your answer
Q57. Reverse a string

You are given a string 'STR'. The string contains [a-z] [A-Z] [0-9] [special characters]. You have to find the reverse of the string.

For example:

 If the given string is: STR = "abcde". You hav...read more
View 2 more answers
Q58. Remove BST keys outside the given range

Given a Binary Search Tree (BST) and a range [min, max], remove all keys which are outside the given range. The modified tree should also be BST.

Input format:

The first l...read more
Add your answer

Q59. Sql query using joins

Ans.

SQL query using joins

  • Use JOIN keyword to combine rows from two or more tables based on a related column between them

  • Types of joins include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN

  • Example: SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column

Add your answer

Q60. Print all Pythagorean triplets within a given range.

Ans.

Print Pythagorean triplets within a given range.

  • Iterate through all possible combinations of a, b, and c within the given range

  • Check if a^2 + b^2 = c^2 for each combination

  • Print the triplets that satisfy the Pythagorean theorem

Add your answer
Q61. BST to greater tree

Given a binary tree with 'N' number of nodes, convert it to a Greater Tree such that data of every node of the original BST is changed to the original node’s data plus the sum of all node’s d...read more

Add your answer

Q62. Design Tic Tac Toe

Ans.

Design a Tic Tac Toe game

  • Create a 3x3 grid to represent the game board

  • Allow two players to take turns marking X and O on the grid

  • Check for win conditions after each move to determine the winner

  • Handle tie game if all spaces are filled without a winner

Add your answer

Q63. Check if given string has Balanced Parentheses.

Ans.

Check if a string has balanced parentheses.

  • Use a stack to keep track of opening parentheses.

  • Iterate through the string and push opening parentheses onto the stack.

  • When a closing parenthesis is encountered, pop from the stack and check if it matches the closing parenthesis.

  • If stack is empty at the end and all parentheses are matched, the string has balanced parentheses.

Add your answer
Q64. Puzzle

You have 10 coins one of them is defective. You have a weight scale. How will you identify the defective coin?

Add your answer
Q65. Data Structures

How to find the pre order traversal of a tree?
State complexity of merge sort
Questions based on radix sort

Add your answer
Q66. Operating System

What will be the result when we will add two binary numbers in 64Bit and 32 Bit operating system?

Add your answer

Q67. Describe in steps how you downloaded any software recently

Ans.

I recently downloaded VLC media player.

  • Visited the official website of VLC media player

  • Clicked on the download button

  • Selected the appropriate version for my operating system

  • Waited for the download to complete

  • Opened the downloaded file and followed the installation wizard

Add your answer

Q68. Guesstimate - how many flights are handled by Bangalore airport on a daily basis

Ans.

Around 600 flights are handled by Bangalore airport on a daily basis.

  • Bangalore airport is one of the busiest airports in India

  • It handles both domestic and international flights

  • On average, there are around 25-30 flights per hour

  • The number of flights may vary depending on the day of the week and time of the year

Add your answer

Q69. Common Elements in two Sorted Linked List

Ans.

Finding common elements in two sorted linked lists.

  • Traverse both lists simultaneously using two pointers.

  • Compare the values of the nodes pointed by the two pointers.

  • If they are equal, add the value to the result list and move both pointers.

  • If not, move the pointer pointing to the smaller value.

  • Repeat until one of the lists is fully traversed.

Add your answer

Q70. Predict Output based on whether static variables can be accessed from non-static method

Ans.

Static variables can be accessed from non-static methods using an object reference or by making the variable non-static.

  • Static variables can be accessed from non-static methods by creating an object of the class containing the static variable.

  • Alternatively, the static variable can be made non-static to be accessed directly from a non-static method.

  • Attempting to access a static variable directly from a non-static method will result in a compilation error.

View 2 more answers

Q71. String a = "Something" String b = new String("Something") How many object created?

Ans.

Two objects created - one in the string pool and one in the heap.

  • String 'a' is created in the string pool, while String 'b' is created in the heap.

  • String pool is a special area in the heap memory where strings are stored to increase reusability and save memory.

  • Using 'new' keyword always creates a new object in the heap, even if the content is the same as an existing string in the pool.

Add your answer

Q72. String a = "Something" a.concat(" New") What will be garbage collected?

Ans.

Only the original string 'Something' will be garbage collected.

  • The concat method in Java does not modify the original string, but instead returns a new string with the concatenated value.

  • In this case, 'a' remains as 'Something' and a new string 'Something New' is created, but not assigned to any variable.

  • Since the new string is not stored in any variable, it will not be garbage collected.

Add your answer

Q73. Delete nth node from end of linked list

Ans.

Delete nth node from end of linked list

  • Use two pointers, one to traverse the list and another to keep track of the nth node from the end

  • Once the nth node is reached, move both pointers until the end of the list

  • Delete the node pointed by the second pointer

Add your answer

Q74. Write code two merge and remove duplicates from two sorted arrays with any Collections

Ans.

Merge and remove duplicates from two sorted arrays without using Collections

  • Use two pointers to iterate through both arrays simultaneously

  • Compare elements at each pointer and add the smaller one to the result array

  • Skip duplicates by checking if the current element is equal to the previous element

Add your answer

Q75. Kth element after merging two sorted arrays

Ans.

Finding the Kth element after merging two sorted arrays.

  • Merge the two sorted arrays into a single array.

  • Sort the merged array.

  • Return the Kth element from the merged and sorted array.

Add your answer

Q76. Difference between 'having' clause and 'where' clause in MySQL

Ans.

HAVING clause is used with GROUP BY to filter groups, WHERE clause is used to filter rows.

  • HAVING clause is used with GROUP BY clause to filter groups based on aggregate functions.

  • WHERE clause is used to filter rows based on conditions.

  • HAVING clause is used after GROUP BY clause, while WHERE clause is used before GROUP BY clause.

  • HAVING clause can use aggregate functions, while WHERE clause cannot.

  • Example: SELECT category, COUNT(*) FROM products GROUP BY category HAVING COUNT(*...read more

Add your answer
Q77. Rewrite code

There were 5 statements code snippets in python. I was told to write that in Java.

Add your answer

Q78. What is inheritance in oops

Ans.

Inheritance in OOP allows a class to inherit properties and behaviors from another class.

  • Inheritance promotes code reusability by allowing a new class to use the properties and methods of an existing class.

  • The class that is being inherited from is called the base class or parent class, while the class that inherits is called the derived class or child class.

  • Derived classes can add new properties and methods, or override existing ones from the base class.

  • Example: class Animal ...read more

Add your answer

Q79. What is oops?

Ans.

OOPs stands for Object-Oriented Programming. It is a programming paradigm based on the concept of objects.

  • OOPs is a way of organizing and designing code around objects

  • It emphasizes on encapsulation, inheritance, and polymorphism

  • It helps in creating reusable and modular code

  • Examples of OOPs languages are Java, C++, Python, etc.

Add your answer

Q80. Write code to emulate Producer/Consumer Problem

Ans.

Emulate Producer/Consumer Problem using code

  • Create a shared buffer between producer and consumer

  • Use synchronization mechanisms like mutex or semaphore to control access to the buffer

  • Implement producer and consumer functions to add and remove items from the buffer respectively

Add your answer

Q81. What knowledge to you have about PL/SQL?

Ans.

PL/SQL is a procedural language designed specifically for the Oracle Database management system.

  • PL/SQL is used to create stored procedures, functions, triggers, and packages in Oracle databases.

  • It is a block-structured language that allows developers to write code in logical blocks.

  • PL/SQL supports data types such as VARCHAR2, NUMBER, DATE, BOOLEAN, etc.

  • It also supports control structures like IF-THEN-ELSE, FOR LOOP, WHILE LOOP, etc.

  • PL/SQL can be used to manipulate data in Ora...read more

Add your answer

Q82. Sort using frequency

Ans.

Sort an array of strings based on their frequency of occurrence.

  • Create a frequency map to count the occurrences of each string

  • Sort the strings based on their frequency in descending order

  • If two strings have the same frequency, sort them lexicographically

  • Return the sorted array

Add your answer

Q83. What is Function overloading and overriding?

Ans.

Function overloading is having multiple functions with the same name but different parameters. Function overriding is redefining a function in a subclass.

  • Function overloading allows multiple functions with the same name but different parameters.

  • Function overriding involves redefining a function in a subclass with the same name and parameters as in the superclass.

  • Example of function overloading: int add(int a, int b) and float add(float a, float b)

  • Example of function overridin...read more

Add your answer

Q84. Camel banana problem

Ans.

The Camel Banana problem is a puzzle that involves calculating the number of bananas a camel can eat.

  • The problem involves a camel that can carry a certain weight and a number of bananas with different weights.

  • The camel can only carry a maximum weight and can only eat a certain number of bananas.

  • The goal is to determine the maximum number of bananas the camel can eat without exceeding its weight limit.

Add your answer

Q85. Rotate a linked list

Ans.

Rotate a linked list

  • Create a new node and make it the head

  • Traverse the list to find the tail and connect it to the old head

  • Update the tail to point to null

  • Handle edge cases like empty list or rotating by 0 positions

Add your answer

Q86. Write code to create a deadlock

Ans.

Creating a deadlock involves two or more threads waiting for each other to release a resource they need.

  • Create two threads, each trying to lock two resources in a different order

  • Ensure that one thread locks resource A first and then tries to lock resource B, while the other thread locks resource B first and then tries to lock resource A

  • This will result in a situation where each thread is waiting for the other to release the resource it needs, causing a deadlock

Add your answer

Q87. Write code to implement LRU Cache

Ans.

Implement LRU Cache using a data structure like LinkedHashMap in Java

  • Use LinkedHashMap to maintain insertion order

  • Override removeEldestEntry method to limit cache size

  • Update the access order on get and put operations

Add your answer

Q88. Product of an array except self

Ans.

Calculate the product of all elements in an array except for the element itself.

  • Iterate through the array and calculate the product of all elements except the current element.

  • Use two separate arrays to store the product of elements to the left and right of the current element.

  • Multiply the corresponding elements from the left and right arrays to get the final result.

Add your answer

Q89. How can you divide a cake into 8 parts only 3 cuts allowed

Ans.

To divide a cake into 8 parts with only 3 cuts, make two perpendicular cuts to create 4 equal pieces, then cut each of those pieces in half.

  • Make a horizontal cut across the middle of the cake to create 2 equal halves.

  • Make a vertical cut through the middle of the cake to create 4 equal quarters.

  • Make a diagonal cut through each quarter to create 8 equal parts.

Add your answer

Q90. Write a program to separate strong for special characters

Ans.

Program to separate strong for special characters in an array of strings

  • Iterate through each string in the array

  • For each string, iterate through each character

  • Check if the character is a special character and separate it into a new string if it is

Add your answer

Q91. Difference between POJO and Bean

Ans.

POJO is a Plain Old Java Object with private fields and public getters/setters, while a Bean is a Java class with private fields and public zero-argument constructors.

  • POJO stands for Plain Old Java Object

  • POJO has private fields and public getters/setters

  • Bean is a Java class with private fields and public zero-argument constructors

  • Beans are usually used in Java EE frameworks like Spring for dependency injection

Add your answer

Q92. Write code to start 5 threads

Ans.

Code to start 5 threads in Java

  • Create a class that implements the Runnable interface

  • Instantiate 5 objects of the class

  • Create 5 threads using the objects and start them

Add your answer

Q93. Write code to read a file

Ans.

Code to read a file in Java

  • Use FileReader and BufferedReader classes to read the file

  • Handle exceptions using try-catch blocks

  • Close the file after reading using close() method

Add your answer

Q94. Find second highest vowel occurance in a string

Ans.

Find the second highest occurrence of a vowel in a string.

  • Iterate through the string and count the occurrences of each vowel (a, e, i, o, u).

  • Store the counts in an array and find the second highest count.

  • Return the vowel with the second highest count.

Add your answer

Q95. Singleton Pattern in details

Ans.

Singleton pattern ensures a class has only one instance and provides a global point of access to it.

  • Ensures a class has only one instance by providing a global access point to it.

  • Uses a private constructor to restrict instantiation of the class.

  • Provides a static method to access the singleton instance.

  • Commonly used in scenarios where only one instance of a class is needed, such as database connections or logging.

  • Example: Singleton pattern can be implemented in Java using a pr...read more

Add your answer

Q96. count no of links in as web page

Ans.

To count the number of links on a web page, you can use a web scraping tool or inspect the page's HTML code.

Q97. Write locator for element in webpage

Ans.

Use CSS selector to locate element on webpage

  • Use unique id or class names to locate element

  • Use CSS selectors like 'id', 'class', 'name', 'tag name', etc.

  • Use XPath if necessary for complex element locating

Add your answer

Q98. Normalization of database to BCNF

Ans.

Normalization to BCNF ensures that every non-trivial functional dependency is satisfied.

  • Identify all functional dependencies

  • Eliminate partial dependencies

  • Eliminate transitive dependencies

  • Ensure every determinant is a candidate key

Add your answer

Q99. how do we measure code quality?

Ans.

Code quality can be measured through various metrics and tools to ensure readability, maintainability, efficiency, and reliability.

  • Use code review processes to assess adherence to coding standards and best practices

  • Utilize static code analysis tools to identify potential bugs, code smells, and security vulnerabilities

  • Measure code complexity using metrics like cyclomatic complexity and maintainability index

  • Track code coverage with unit tests to ensure adequate test coverage

  • Mon...read more

Add your answer

Q100. What is Polymorphism?

Ans.

Polymorphism is the ability of an object to take on many forms.

  • Polymorphism allows objects of different classes to be treated as objects of a common superclass.

  • It enables methods to be overridden in a subclass to provide different implementations.

  • Polymorphism enhances code reusability and flexibility.

  • Example: A superclass 'Animal' with subclasses 'Dog' and 'Cat' can be treated as 'Animal' objects.

  • Example: Method 'draw()' in superclass 'Shape' can be overridden in subclasses '...read more

Add your answer
1
2

More about working at Oracle

#22 Best Mega Company - 2022
#3 Best Internet/Product Company - 2022
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at Diligenta 2

based on 363 interviews in the last 1 year
Interview experience
4.1
Good
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions from Similar Companies

3.7
 • 406 Interview Questions
4.2
 • 195 Interview Questions
4.2
 • 177 Interview Questions
3.6
 • 170 Interview Questions
3.5
 • 146 Interview Questions
3.4
 • 138 Interview Questions
View all
Top Oracle Interview Questions And Answers
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter