Java Developer Interview Questions
- 0of 0 votes
AnswersWhat does the expression float a = 35 / 0 return?
- hr@zynofus.com December 31, 2021 in India
a) 0
b) Not a Number
c) Infinity
d) Run time exception
Answer : c| Report Duplicate | Flag | PURGE
Zynofus Technologies Pvt. Ltd. Java Developer Java - 0of 0 votes
AnswersWhich of the following is a valid long literal?
- hr@zynofus.com December 31, 2021 in India
a) ABH8097
b) L990023
c) 904423
d) 0xnf029L
Answer : d| Report Duplicate | Flag | PURGE
Zynofus Technologies Pvt. Ltd. Java Developer Java - 0of 0 votes
AnswersWhat is the return type of the hashCode() method in the Object class?
- hr@zynofus.com December 31, 2021 in India
a) Object
b) int
c) long
d) void
Answer : b| Report Duplicate | Flag | PURGE
Zynofus Technologies Pvt. Ltd. Java Developer Java - 0of 0 votes
AnswersWhich of the following is a valid declaration of a char?
- hr@zynofus.com December 31, 2021 in India
a) char ch = '\utea';
b) char ca = 'tea';
c) char cr = \u0223;
d) char cc = '\itea';
Answer : a| Report Duplicate | Flag | PURGE
Zynofus Technologies Pvt. Ltd. Java Developer Java - 0of 0 votes
Answers_____ is used to find and fix bugs in the Java programs.
- hr@zynofus.com December 31, 2021 in India
a) JVM
b) JRE
c) JDK
d) JDB
Answer : d| Report Duplicate | Flag | PURGE
Zynofus Technologies Pvt. Ltd. Java Developer Java - 0of 0 votes
AnswersThe \u0021 article referred to as a
- hr@zynofus.com December 31, 2021 in India
a) Unicode escape sequence
b) Octal escape
c) Hexadecimal
d) Line feed
Answer : a| Report Duplicate | Flag | PURGE
Zynofus Technologies Pvt. Ltd. Java Developer Java - 0of 0 votes
AnswersWhich of the following option leads to the portability and security of Java?
- hr@zynofus.com December 31, 2021 in India
a) Bytecode is executed by JVM
b) The applet makes the Java code secure and portable
c) Use of exception handling
d) Dynamic binding between objects
Answer : a| Report Duplicate | Flag | PURGE
Zynofus Technologies Pvt. Ltd. Java Developer Java - 16of 16 votes
Answers Given Two array with the preference of two developers say Ying and Ming, both need to create a team according to the preference, you need to return the String containing the Initial of the team the developers got selected it Note: Ying will always got the chance to make a first pick? {{{Example says Ying Preference table [1,2,3,4] and Ming Preference table is [1,2,3,4] than the Output should be 'YMYM' 2nd Example Ying Preference input array [1,3,2] and Ming Preference input array is [3,1,2] than the String return would be 'YYM'. - sam21088 June 22, 2020 in India for PWM| Report Duplicate | Flag | PURGE
Morgan Stanley Java Developer Algorithm - 0of 0 votes
AnswersJava:
- roxanadaniela35 April 10, 2020 in United States
Managing extreme sports locations:
In such locations, are period of the year when this actities can be performed(ski December - February, Kiting May August, ATV all year), each sport /location usually has an average cost/day.
The sports have hierarcal structure and countaind the country, region and city, we need an ADD, REMOVE, UPDATE; GET a location and all its informations.
exemple:
Switzerland:
Zurich:sky(dec, feb), price 12 $
Berna:ATV - all time , price 10$| Report Duplicate | Flag | PURGE
JDA Java Developer Java - 0of 0 votes
AnswersN number of balloons are kept at different heights. You are asked to find out number of arrows to burst them. When an arrow hits the balloon it goes one level down.
- Raj June 27, 2019 in United States
Assume that the balloons are having same size.
for example given the balloons heights as array(Array will be given in decreasing order of size) :
5 4 3 3 2 2 1 1 1
minimum number of arrows to shoot them is: 3
explanation:
using first arrow shoot: 5 4 3 2 1
using second arrow shoot: 3 2 1
using third arrow shoot: 1
Example 2:
5 4 2 1
minimum number of arrows to shoot them is: 2
using first arrow shoot: 5 4
using second arrow shoot: 2 1
Expecting the solution to be in O(1) space complexity.| Report Duplicate | Flag | PURGE
Walmart Labs Java Developer Algorithm - 0of 0 votes
AnswersYou are required to collect N numbers from a bag. Initially, the bag is empty. Whenever you put a number X in the bag, then the owner of the bag asks the question.
- Sameer June 21, 2019 in United States
The questions are as follows:
. What is the greatest integer that is smaller than X and present inside the bag?
. What is the smallest number that is greater than X and present inside the bag?
If you answer both the questions correctly, then you can put X inside the bag. Your task is to answers the questions that are asked by the owner of the bag. If no such numbers exist in the bag print -1.
Example:
5 (Number of elements in the bag)
1
4
2
3
7
output:
-1 -1
1 -1
1 4
2 4
4 -1| Report Duplicate | Flag | PURGE
Amazon Java Developer Data Structures - 5of 5 votes
AnswersA happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers.
- sk2244 March 19, 2019 in India
Input:
Your program should read lines of text from standard input. Each line contains a single positive integer, N.
Output:
If the number is a happy number, print 1 to standard output. Otherwise, print 0.| Report Duplicate | Flag | PURGE
Sabre Holdings Java Developer Java - 0of 0 votes
AnswersMaximum Pairs
You are given N pencils. You have to make pairs of pencils.
The condition for making pairs is:
If(a,b) is any pair of pencils then b >= 2 * a. Here a and b are the sizes of pencils.
Now you have to find out the number of such pairs and the number of pencils which could not be paired with any pencils.
Note:
You need to pair the pencils in such a manner that the maximum number of pairs are formed.
Input Format:
The first line consists of number of test case T.
Each test case consist of:
- First line consists of a single integer N.
- Second line consists of N space-separated integers denoting the size of pencils Si.
Output Format:
For each test case, print two space-separated integers, first denoting the number of pairs formed and second denoting the number of unpaired pencils.
Answer for each test case should come in a new line.
Constraints
1<T<=10
1<=N<=10^5
0<=Si<=10^5
Sample Input
2
5
1 2 3 4 5
4
1 2 4 4
Sample Output
2 1
2 0
Explanation
In the first test case:-
we can form the following pairs:
(1, 3), (2, 4) and 5 remains unpaired hence maximum pairs are 2
In second test case:-
(1, 4), (2, 4) are two pairs hence no pencil left unpaired
- Karan Khosla January 04, 2019 in United States for 4public class Test { public static void main(String[] args) { } static int[] solve(int[] arr) { // the value at first index of array to be returned is number of pairs // formed and value at second index is unpaired swords. } }
| Report Duplicate | Flag | PURGE
Java Developer Java - 0of 0 votes
Answerswhat is default pakg in java
- sajidaliit36 November 08, 2018 in United States| Report Duplicate | Flag | PURGE
Nisum Technologies Java Developer - 0of 0 votes
Answersany one can tell what is special modifers in java.
- sajidaliit36 November 08, 2018 in United States| Report Duplicate | Flag | PURGE
Nisum Technologies Java Developer - 0of 0 votes
AnswersMulti -level cache system design with different storage in each level.
- ANONU June 22, 2018 in United States
Read Operation : – Minimum time to read a particular key from cache system. This should be followed by writing the key in all levels above it. Eg. if “key” is found at level ‘i’, add this key to cache present at 1 to i-1 level.
b. Write Operation: – Any write Operation should write in cache of all levels.
You can choose any algorithm for cache management like LRU, MRU.| Report Duplicate | Flag | PURGE
Google Java Developer Coding - 0of 0 votes
Answershttps://codejamanalysis.wordpress.com/2017/03/18/crossover-problem-super-stack/
- akshaysjk June 13, 2018 in United States
Any Optimized Solution to avoid TLE for 4 test cases. I have tried by implementing Stack using Doubly Linked List.
Still not able to pass test cases!!!| Report Duplicate | Flag | PURGE
Java Developer Data Structures Java Stacks - 0of 0 votes
Answers1. There is a list of 20 words. 10 of them are good works, and 10 of them are bad words. Write a regex of not more than 25 characters which would tell if given word is good or bad. Input would only contain one of these 20 words.
- Ashish Dass June 02, 2018 in India
Good words: papa, book, home, cars, jolly, sugar, friend, mother, father, bloomiest
Bad words: ache, slow, torn, slum, boom, rival, wrong, cholera, revenge, arrogant
Input: book
Output: Good
Input: boom
Output: bad| Report Duplicate | Flag | PURGE
Adobe Java Developer Java - 0of 0 votes
AnswersDesign a system like github.
- ANONU May 29, 2018 in India| Report Duplicate | Flag | PURGE
Google Java Developer Software Design - 0of 0 votes
AnswersWhat is the issue with this Producer Consumer Problem. Can you fix it.
- dadakhalandhar May 26, 2018 in Indiapublic class ProducerConsumerProb { public static void main(String[] args) { Container container = new Container(); Turn turn = Turn.PRODUCER; Producer p = new Producer(container, turn); Consumer c = new Consumer(container, turn); Thread pro = new Thread(p); Thread con = new Thread(c); pro.start(); con.start(); } public static class Producer implements Runnable{ Container container; Turn turn; public Producer(Container integer,Turn turn) { this.container = integer; this.turn = turn; } @Override public void run() { for(int i=0;i<10;i++){ Turn temp = null; while(true){ synchronized (turn) { temp = turn; } if(temp == Turn.PRODUCER){ break; } } synchronized (turn) { container.setI(i); turn = Turn.CONSUMER; } } } } public static class Consumer implements Runnable{ Container container; Turn turn; public Consumer(Container integer,Turn turn) { this.container = integer; this.turn = turn; } @Override public void run() { for(int i=0;i<10;i++){ Turn temp = null; while(true){ synchronized (turn) { temp = turn; } if(temp == Turn.CONSUMER){ break; } } synchronized (turn) { System.out.println(container.getI()); turn = Turn.PRODUCER; } } } } public static class Container{ Integer i = new Integer(0); public int getI() { return i; } public void setI(int i) { this.i = i; } } enum Turn{ PRODUCER,CONSUMER; } }
| Report Duplicate | Flag | PURGE
Infinera Java Developer Java - 0of 0 votes
AnswersThere are hierarchy of class like super class and sub class. Yo have to make sure only one object can be create for any class using new keyword. How you implement the class.
- Randhir May 23, 2018 in United States| Report Duplicate | Flag | PURGE
Wissen Technology Java Developer Java - 0of 0 votes
AnswersList<Integer> list=Arrays.asList(1,2,3,4,5,6);
- Randhir May 14, 2018 in India
Iterator it=list.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
The above code will iterate sequentially through 1 to 6. Can we iterate the same list alternatively so that it will print 1,3,5 without changing the while loop.| Report Duplicate | Flag | PURGE
Wissen Technology Java Developer Java - 0of 0 votes
AnswersYou are given a string S consisting of lowercase English letters denoting different types of candies. A substring of a string S is a string S' that occurs in S. For example, "bam" is a substring of "babammm". Each candy costs 1 unit. You can pick some continuous candies such that you can create a palindrome of length K by using some or all picked candies. Your task is to find the minimum cost to create a palindrome of length K.
- rahul123625 May 06, 2018 in India
Input Format:
First line contains string S.
Next line contains an integer T denoting the number of test cases.
Next T lines contain a single integer K.
Output Format:
For each test case, print minimum cost as mentioned above. If you cannot create a palindrome of length K then, simply print -1.
Constraints:
Constraints:
1≤|S|≤10^5
1≤T≤10
1≤K≤10^5
Sample Input
babammm
2
2
5
Sample Output
2
5
Explanation
Test Case 1: You can pick candies denoted by "mm" and create a palindrome of size 2. So the cost will be 2 units.
Test Case 2: You can pick candies denoted by "babam" and rearrange them, "bamab", to create a palindrome of size 5. So the cost will be 5 units.| Report Duplicate | Flag | PURGE
makemytrip Java Developer - 0of 0 votes
AnswersNumbers with 4 are considered to be unlucky, floor numbers are skipped with numbers with 4; for a top level n, ask how many layers there are actually; for example n=20, that is 18 levels [Remove 4, 14]
- ajay.raj April 28, 2018 in United States| Report Duplicate | Flag | PURGE
Amazon Java Developer - 0of 0 votes
AnswersInput unsorted integer array represents a list of coins,
- ajay.raj April 18, 2018 in United States
find the minimum amount of money that cannot be formed by these coins, each coin can only be used once
E.g. {1,1} -> 3, {1,2,4} -> 8| Report Duplicate | Flag | PURGE
Amazon Java Developer - 0of 0 votes
Answerspublic TreeNode{
int val = val;
TreeNode left, right;
public TreeNode(int val){
this.val = val;
}
given a tree and an API, delete a part of the nodes in the tree and return the forest formed after the node is deleted.
public List<TreeNode> deletenodes(TreeNode root, List<TreeNode> toDeletes){
}
example
- ajay.raj March 28, 2018 in United States1 / \ 2 3 / / \ 4 5 6 If you delete the 2 and 5 nodes, you will need to return to the forest [4, 1] \ 3 \ 6
| Report Duplicate | Flag | PURGE
Amazon Java Developer - 0of 0 votes
AnswersGiven: Collection of sorted (ascending) iterators which return integer value.
Implement hasNext() and next() methods in SuperIterator class that next() method should return sorted values from all iterators.
Note that we can't load all iterators to memory, because they might get values from big file (1TB for instance) and it will lead to OutOfMemoryError.
- mhenro March 21, 2018 in United States/* iter1: 1, 4, 5, 20, ... iter2: 2, 10, 12, 50, ... SuperIterator.next() method should return: 1, 2, 4, 5, 10, 12, 20, 50, ... */ interface Iterator { boolean hasNext(); int next(); } class SuperIterator { public SuperIterator(Collection<Iterator> iters) { } boolean hasNext() { //TODO } int next() { //TODO } }
| Report Duplicate | Flag | PURGE
Java Developer Java - 0of 0 votes
AnswersThere is a process sequence that contains the start and end of each process. There is a query sequence asking how many processes are running at a certain point in time. Please return the query result of the query sequence.
- ajay.raj March 05, 2018 in United States
Example
Given logs = [[1, 1234], [2, 1234]], queries = [2], return [2].
Explanation:
There are 2 processes running at time 2.
Given logs = [[1, 1234], [2, 1234]], queries = [1, 1235], return [1, 0].
Explanation:
There is a process running at time 1, and 0 processes running at time 1235.| Report Duplicate | Flag | PURGE
Amazon Java Developer - -1of 1 vote
AnswerGiven:
- ajay.raj March 05, 2018 in United States
R number of Red Cards
B number of Black cards
K
Cards needs to be placed in a circle. Start from a position and for
every K moves remove that card And
repeat the process until all the cards are eliminated.
Question: Position the cards such that the red cards are completely
eliminated before the blacks cards are selected for elimination.| Report Duplicate | Flag | PURGE
Amazon Java Developer