Java Interview Questions
- 0of 0 votes
Answerswhat is the difference between internal repository and internet repository?
- Muni July 09, 2014 in India| Report Duplicate | Flag | PURGE
Infosys Software Engineer / Developer Java - 0of 0 votes
Answerswhat about your project performance...how can i answer this question?
- Muni July 08, 2014 in India| Report Duplicate | Flag | PURGE
Infosys Software Engineer / Developer Java - 0of 0 votes
AnswersHow to convert http to https in java....can anyone knows please tell me?
- Muni July 08, 2014 in India| Report Duplicate | Flag | PURGE
Infosys Software Engineer / Developer Java - 2of 2 votes
AnswersGiven a String with print all the possible combinations of the all the characters in the string as a string for Example
- Anirudh July 05, 2014 in India
"abc" is the input the you should print the below:
abc
ab
ac
a
bc
b
c
There is one invisible string which is actually a blank string.| Report Duplicate | Flag | PURGE
Komli Media SDET Java - 0of 0 votes
AnswersGiven a string that contains exactly a single pair of parenthesis, return parenthesis and their contents, so "xyz(abc)123" yields "(abc)". etc.
- Anirudh July 03, 2014 in India
Condition: You are not allowed to use a variable anywhere, Regex is not allowed.| Report Duplicate | Flag | PURGE
Ibibo Software Engineer / Developer Java - 0of 0 votes
AnswersGiven a string that contains exactly a single pair of parenthesis, return parenthesis and their contents, so "xyz(abc)123" yields "(abc)". etc.
- Anirudh July 03, 2014 in India
Condition: You are not allowed to use a variable anywhere.| Report Duplicate | Flag | PURGE
Ibibo Software Engineer / Developer Java - 0of 0 votes
AnswersString="welcome bangalore" i want erolagnab welcome how to reverse this string..can anyone knows pls answer this one.
- Muni June 30, 2014 in India| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
Answerswrite a java program consider a text file,that file is having N number of lines.how to print last N lines..
- Muni June 28, 2014 in India| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersLakshmi is a primary school teacher. She wants to give some laddus to the children in her class. All the students sit in a line and each of them has a rating score according to his or her usual performance. Lakshmi wants to give at least 1 laddu for each child. Children get jealous of their immediate neighbors, so if two children sit next to each other then the one with the higher rating must get more laddus. Lakshmi wants to save money, so she wants to minimize the total number of laddus.
- Anonymous June 15, 2014 in United States
Tip: Please understand the question clearly and pay good attention to below provide - sample input and output - completely in order to arrive at correct solution.
Input
The first line of the input is an integer N, the number of children in Lakshmi's class. Each of the following N lines contains an integer indicates the rating of each child.
Ouput
Output a single line containing the minimum number of laddus Lakshmi must give.
Explanation
Sample Input
3
1
2
2
Sample Ouput
4
Explanation
The number of laddus Lakshmi must give are 1, 2 and 1.| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersBase class is given you need to stop exposing the base class methods without touching the base class at all.
- hareendrareddy June 07, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Java - -2of 2 votes
AnswersThe boggle game - given a 2d array of characters
- FauxPas June 07, 2014 in United States| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Algorithm Coding Java - 1of 1 vote
AnswersEvaluate a given mathematical expression, taking into consideration the BODMAS rule. The expression contains no brackets.
- FauxPas June 07, 2014 in United States| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Algorithm Coding Java - 0of 0 votes
AnswersSerialize and deserialize a tree.
- FauxPas June 07, 2014 in United States
Given a tree - not necessarily a binary tree - the serialize method should create a string for the tree. The deserialize method should be able to reproduce the same tree using the string derived from the serialize method.
Basically, serialize() takes in a tree and returns a string, deserialize() takes in a string and returns the tree.| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Algorithm Coding Java Object Oriented Design - 0of 0 votes
AnswersString d1="7 dec 2012";
- alis June 06, 2014 in India
String d2="15 dec 2012";
String d3="12 dec 2012";
String d4="16 dec 2012";
String d5="16 dec 2012";
String d6="24 dec 2012";
days between d1 and d2 is: 9
days between d3 and d4 is: 1 (12 dec to 15 dec counted in d1 and d2, don't count overlapping days)
days between d3 and d4 is: 8 (16 dec counted in d3 and d4, don't count overlapping days)
now final output should be: 9 + 1 + 8=18| Report Duplicate | Flag | PURGE
Tricon Java Developer Java - 7of 7 votes
AnswersGiven a string (for example: "a?bc?def?g"), write a program to generate all the possible strings by replacing ? with 0 and 1.
- pennepalli May 30, 2014 in United States
Example:
Input : a?b?c?
Output: a0b0c0, a0b0c1, a0b1c0, a0b1c1, a1b0c0, a1b0c1, a1b1c0, a1b1c1.| Report Duplicate | Flag | PURGE
Google Developer Program Engineer Algorithm C# C++ Java - 1of 1 vote
Answers
- ps May 27, 2014 in United StatesGiven the following directory structure: org | -- Robot.class | -- ex |-- Pet.class | |-- why |-- Dog.class And the following source file: class MyClass { Robot r; Pet p; Dog d; Which statement(s) must be added for the source file to compile? (Choose all that apply.) A. package org; B. import org.*; C. package org.*; D. package org.ex; E. import org.ex.*; F. package org.ex.why; G. package org.ex.why.Dog;
| Report Duplicate | Flag | PURGE
Software Engineer in Test Java - 0of 0 votes
AnswersHere is a small program which will be of my help.
- sharathchitra May 23, 2014 in India
Please code it in JAVA. If you are successful, please send me the code as early as possible by tomorrow.
If you are not able to get, please send me the update.
The Definition is given as below:
1. A File contains string for Example: GCDNPQACKSPEGF...FIM
2. Read each character from this file and ASSIGN the values as below:
A,C,S = 3
F,D,N,T= 4
P,F,Y = 9
M,E,G = 2
Q,H,I,K,R,L = 6
3. AFTER ASSIGNING CHECK THE FILE FOR MAPPING
4. Sum THE VALUES in that sequence for Eg: 2+ 3+ 4...... = SUM = 60
5. FIND THE total LENGTH of the sequence for E: L = 20
6. Find the AVERAGE A = SUM/L =60/20 =3
7. USE THE PATTERNS as triplets from the same file as given below AND CALCULATE EACH PATTERN'S WEIGHTAGE as for Eg:
GCD = 2 + 3 + 4 = 9 (G = 2, C=3, D=4 from the mapping)
CDN = 3+4+4 = 11
...........
for all possible patterns
8. FinD THE MAXIMUM OF ALL THE PATTERN'S WEIGHTAGE
So, the o/p should be : Average -->
Triplet and its Weightage as :GCD : 2 + 3+ 4 = 9 for all possible triplets
Maxi Weightage -->| Report Duplicate | Flag | PURGE
Student student Java Developer Java - 0of 0 votes
AnswersA matrix will be given which contains nos. and dots. will have to output another matrix in which the nos. are surrounded by single loop. the value of each number in a matrix equals the number of lines surrounding it.
- im.akki90 May 23, 2014 in India
Empty spaces in matrix/dots may be surrounded by any number of lines.
When completed, the solution forms a single continuous loop with no crossings or branches.
Value of each no. should connect the adjacent dots horizontally and vertically so that the lines form a simple loop with no loose ends based on the above rules.
eg
input Matrix
1.31.3
...3..
.3.21.
.02.1.
..2...
2.23.3
output Matrix
- -
1 .|3|1 .|3|
- - | - |
|. . .|3|. .|
| - - -
|.|3|. 2 1|.
- - - _
. 0 2 .|1 .|
- - - -
|.|.|2 . .|.
| - - -
|2 . 2|3|. 3|
- - - - -
i tried making rules and then call the function to make lines, but couldnt succeed in gettin desired output.
for any queries please comment| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer Java - 0of 0 votes
AnswersA matrix will be given which contains nos. and dots. will have to output another matrix in which the nos. are surrounded by single loop. the value of each number in a matrix equals the number of lines surrounding it.
- im.akki90 May 23, 2014 in India
Empty spaces in matrix/dots may be surrounded by any number of lines.
When completed, the solution forms a single continuous loop with no crossings or branches.
Value of each no. should connect the adjacent dots horizontally and vertically so that the lines form a simple loop with no loose ends based on the above rules.
eg
input Matrix
1.31.3
...3..
.3.21.
.02.1.
..2...
2.23.3
output Matrix
- -
1 .|3|1 .|3|
- - | - |
|. . .|3|. .|
| - - -
|.|3|. 2 1|.
- - - _
. 0 2 .|1 .|
- - - -
|.|.|2 . .|.
| - - -
|2 . 2|3|. 3|
- - - - -
i tried making rules and then call the function to make lines, but couldnt succeed in gettin desired output.
for any queries please comment| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer Java - 1of 1 vote
AnswersMultiple threads are running in my program. Exception occurs in one of the thread. There is no exception handling done.
- vijayinani May 23, 2014 in India
What will happen to my program? Will it terminate the complete program? What will happen to other threads?| Report Duplicate | Flag | PURGE
Credit Suisse Software Engineer / Developer Java - 0of 0 votes
Answersi) Explain Polymorphism
ii) Output of the below code snippet :-
- hulk May 15, 2014 in Indiapublic class ParentTest { public int x = 0; public void print() { System.out.println("In Parent"); } } public class ChildTest extends ParentTest { public int x = 1; public void print() { System.out.println("In Child"); } public static void main( String args[] ) { ParentTest s = new ChildTest(); System.out.println(s.x); s.print(); } }
| Report Duplicate | Flag | PURGE
Morgan Stanley Software Engineer / Developer Java - 0of 0 votes
AnswersIn synchronous request from browser how do you get results if you have to access 2 different databases
- cheeta May 14, 2014 in United States| Report Duplicate | Flag | PURGE
Citigroup Java Developer Java - 0of 0 votes
AnswersIn assembly line situation, how do you pass a job from thread1 to thread2 to thread3?
- cheeta May 14, 2014 in United States| Report Duplicate | Flag | PURGE
Citigroup Java Developer Java - 0of 0 votes
Answerin a web request you want to send results to the browser/client only if the caching operation goes success. how do you accomplish this.
- cheeta May 14, 2014 in United States| Report Duplicate | Flag | PURGE
Citigroup Java Developer Java - 0of 0 votes
Answerspublic class Gen { public static void main(String[] args) { Integer i1 = new Integer(1); Integer i2 = new Integer(1); System.out.println(i1 != i2); System.out.println(i1 <= i2); System.out.println(i1 >= i2); } }
WHY THE OUTPUT IS TRUE IN ALL CASES?
- onlinesoumitra May 10, 2014 in India| Report Duplicate | Flag | PURGE
Infosys Analyst Java - 0of 0 votes
AnswersA non-empty zero-indexed array A consisting of N integers is given. The leader of this array is the value that occurs in more than half of the elements of A.
- Mehaboob557 May 03, 2014 in India
Write a function:
int arrLeader(int A[], int N);
int arrLeader(NSMutableArray *A);
int arrLeader(const vector<int> &A);
class Solution { int arrLeader(int[] A); }
class Solution { public int arrLeader(int[] A); }
function arrLeader(A);
function arrLeader(A)
function arrLeader($A);
function arrLeader(A : array of longint; N : longint) : longint;
def arrLeader(A)
sub arrLeader { my (@A)=@_; ... }
def arrLeader(a)
Private Function arrLeader ( A As Integer() ) as Integer
that, given a non-empty zero-indexed array A consisting of N integers, returns the leader of array A. The function should return -1 if array A does not contain a leader.
Assume that:
l N is an integer within the range [1..1,000,000];
l each element of array A is an integer within the range [0..2,147,483,647].
For example, given array A consisting of ten elements such that:
A[0] = 4 A[1] = 2 A[2] = 2 A[3] = 3 A[4] = 2 A[5] = 4 A[6] = 2 A[7] = 2 A[8] = 6 A[9] = 4
the function should return -1, because the value that occurs most frequently in the array, 2, occurs 5 times, and 5 is not more than half of 10.
Given array A consisting of five elements such that:
A[0] = 100 A[1] = 1 A[2] = 1 A[3] = 50 A[4] = 1
the function should return 1.
Complexity:
l expected worst-case time complexity is O(N);
l expected worst-case space complexity is O(1), beyond input storage (not counting the storage required for input arguments).
Elements of input arrays can be modified.
// you can also use includes for example:
// #include <algorithm>
int arrLeader ( const vector<int> &A ) {
// write your code here
}| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersImplement multiple producer and multiple consumer problem in java.
- hulk May 03, 2014 in India| Report Duplicate | Flag | PURGE
Infibeam SDE-2 Java