## Java Interview Questions

- 0of 0 votes
[Phone screen]

Tell me about the Java Collections framework, what are its main interfaces. OK, what are the main differences between the Set and List interfaces? What do you give up if you go from a List to a Set, and what do you get in exchange for this if you go from a List to a Set? How would you go about guessing the order of an iteration() of HashSet if I told you I was going to insert the strings "first", "second", "third", "forth", and "fifth"?

- 0of 0 votes
Tell me about the Java Collections framework, what are its main interfaces. OK, what are the main differences between the Set and List interfaces? What do you give up if you go from a List to a Set, and what do you get in exchange for this if you go from a List to a Set? How would you go about guessing the order of an iteration() of HashSet if I told you I was going to insert the strings "first", "second", "third", "forth", and "fifth"?

- 0of 0 votes
[Phone screen]

Tell me what you know about the java.lang.Object class. OK, what are best practices for the equals method? How would you implement an equals method for a class with 100s of data fields?

- 0of 0 votes
Write a Program to find out Whether a given String can be a Palindrome i.e. we need to see for the palindrome after rearranging the words in that string.

example: lets say we have a string "aabbccd" so it can be a palindrome after rearranging the words "abcdcba".

For this I need to find out the optimal solution.

- 0of 0 votes
Write a Program to find out that a given String can be a Palindrome.we need to see for the palindrome after rearranging the words in that string.

example: lets say we have a string "aabbccd" so it can be a palindrome after rearranging the words "abcdcba".

For this I need to find out the optimal solution.

- 0of 0 votes
Design a system like friend's functionality in facebook. should have all features of facebook's friends functionality. like for each person , he can have any number of friends , he will get suggestions for new firends , showing common friends if we visits any other profile . algo should be scalable , robust .

- 0of 0 votes
what is the difference between internal repository and internet repository?

- 0of 0 votes
what about your project performance...how can i answer this question?

- 0of 0 votes
How to convert http to https in java....can anyone knows please tell me?

- 2of 2 votes
Given a String with print all the possible combinations of the all the characters in the string as a string for Example

"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.

- 0of 0 votes
Given a string that contains exactly a single pair of parenthesis, return parenthesis and their contents, so "xyz(abc)123" yields "(abc)". etc.

Condition: You are not allowed to use a variable anywhere, Regex is not allowed.

- 0of 0 votes
Given a string that contains exactly a single pair of parenthesis, return parenthesis and their contents, so "xyz(abc)123" yields "(abc)". etc.

Condition: You are not allowed to use a variable anywhere.

- 0of 0 votes
Write a java program for Fibonacci series...in this format

{1, 1, 2, 3, 5, 8, 13, 21, 34, 55,}print {1,1,#,3,5,#,13,21,#,55}instead of even numbers print #..how to solve this question

- 0of 0 votes
String="welcome bangalore" i want erolagnab welcome how to reverse this string..can anyone knows pls answer this one.

- 0of 0 votes
int[] a1={1,3,5,7} int[] a2={3,6,8,9} int[] a3={}...

Merge first two arrays in a sorted order result put it in third array output will be{1,3,3,5,7,8} write a code for this one?

- 0of 0 votes
write a java program consider a text file,that file is having N number of lines.how to print last N lines..

- 0of 0 votes
string[][] names={{"perk","parker"},{"jhon","raj"},{"ram","lakshman"}};

write a java program print lastname,then firstname in sorted order without using string.compareTo,collections.sort,arrays.sort

- 0of 0 votes
Lakshmi 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.

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.

- 0of 0 votes
Base class is given you need to stop exposing the base class methods without touching the base class at all.

- -1of 1 vote
The boggle game - given a 2d array of characters

- 0of 0 votes
Evaluate a given mathematical expression, taking into consideration the BODMAS rule. The expression contains no brackets.

- 0of 0 votes
Serialize and deserialize a tree.

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.

- 0of 0 votes
String d1="7 dec 2012";

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

- 1of 1 vote
Given a string (for example: "a?bc?def?g"), write a program to generate all the possible strings by replacing ? with 0 and 1.

Example:

Input : a?b?c?

Output: a0b0c0, a0b0c1, a0b1c0, a0b1c1, a1b0c0, a1b0c1, a1b1c0, a1b1c1.

- 0of 0 votes
`Given 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;`

- 0of 0 votes
Here is a small program which will be of my help.

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

- 0of 0 votes
A 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.

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

- 0of 0 votes
A 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.

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

- 0of 0 votes
Multiple threads are running in my program. Exception occurs in one of the thread. There is no exception handling done.

What will happen to my program? Will it terminate the complete program? What will happen to other threads?

- 0of 0 votes
i) Explain Polymorphism

ii) Output of the below code snippet :-`public 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(); } }`