Java Interview Questions
- 0of 0 votes
AnswerWhich interface is intended to supersede Enumeration in the collections framework?
- dhaval0129 July 26, 2011| Report Duplicate | Flag | PURGE
Bloomberg LP Java - 0of 0 votes
Answersclass SuperClass {
- dhaval0129 July 26, 2011
private void printIt() {System.out.println("SuperClass");}
void printIt(boolean f) {
if (f) {
System.out.println("Super-part 2");
} else {
printIt();
}
}
}
class SubClass extends SuperClass {
void printIt() {System.out.println("SubClass");}
}
public class TestSub {
static void main(String args[]) {
SubClass sc=new SubClass();
sc.printIt();
sc.printIt(false);
}
}| Report Duplicate | Flag | PURGE
Bloomberg LP Java - 0of 0 votes
Answers// *** Line A
- dhaval0129 July 26, 2011
package com.brainbench.TestExamples;
// *** Line B
import java.io.*;
// *** Line C
public class DocumentationSample
// *** Line D
implements Serializable {
// *** Line E
// .. Code not shown ..
}
In the code sample above, where must you place a documentation comment that describes the purpose of the class DocumentationSample?| Report Duplicate | Flag | PURGE
Bloomberg LP Java - 0of 0 votes
Answerspublic class ArrayTest{
- dhaval0129 July 26, 2011
public static void main(String[] args){
// insert code here
}
}
Given the above sample code, what do you insert to print out a list of the command-line arguments?
a.) for(int i=0; i<args.getLength(); i++)
System.out.println(args[i]);
b.) for(int i=0; i<args.size(); i++)
System.out.println(args[i]);
c.) for(int i=0; i<args.length(); i++)
System.out.println(args[i]);
d.) for(int i=0; i<args.length; i++)
System.out.println(args[i]);
e.) for(int i=0; i<sizeof(args); i++)
System.out.println(args[i]);| Report Duplicate | Flag | PURGE
Bloomberg LP Java - 0of 0 votes
Answers<%@ page language="java" import="java.io.*" %>
- dhaval0129 July 26, 2011
<HTML>
<BODY>
The browser's IP address was:
<%-- *** Line A *** --%>
</BODY>
</HTML>
When substituted for Line A in the JSP code above, which one of the following lines displays the browser's IP address?
a.) <%= session.getRemoteAddr() %>
b.) <%= request.getRemoteAddr() %>
c.) <%= application.getRemoteAddr() %>
d.) <%= page.getRemoteAddr() %>
e.) <%= response.getRemoteAddr() %>| Report Duplicate | Flag | PURGE
Bloomberg LP Java - 0of 0 votes
Answerschar ch1 = 0,ch2 = 0; try { ch1 = (char) System.in.read(); } catch(Exception e) {} switch(ch1) { case 'a': ch2 = '1'; case 'b': ch2 = '2'; case 'c': ch2 = '3'; default: ch2 = '4'; }
In reference to the above, if during execution the user presses "b," what is the ending value of "ch2"?
- dhaval0129 July 26, 2011| Report Duplicate | Flag | PURGE
Bloomberg LP Java - -1of 1 vote
Answerspublic class SortSample {
- dhaval0129 July 26, 2011
public void printSorted(int arrayToSort[]) {
.. // Insert code to sort the array here
System.out.print("Sorted array is ");
for (int j=0; j<arrayToSort.length;j++)
System.out.print(arrayToSort[j]+" ");
System.out.println();
}
In the above code, what is the code-efficient way to sort the array into ascending order?| Report Duplicate | Flag | PURGE
Bloomberg LP Java - -1of 1 vote
Answerspublic class CashHolder {
- dhaval0129 July 26, 2011
private double amountHeld=0.0;
}
public void getCash() {
CashHolder wallet = new CashHolder();
// Lookup the Teller using RMI
Teller teller= (Teller) java.rmi.
Naming.lookup("//localhost/TellerObject");
// Withdraw 100.00 from account #9856432 and put it into
// Wallet.
teller.withdrawFunds("9856432",wallet,100.00);
// Go somewhere and spend it
..
}
How do you change the code above to allow teller.withdrawFunds() to update the CashHolder object passed to it?| Report Duplicate | Flag | PURGE
Bloomberg LP Java - 0of 0 votes
AnswersHow do you implement abstraction and encapsulation? Explain with example.
- Anonymous July 24, 2011| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersHow to find a first non repeating character in a String ?
- Nikhil July 21, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Java - 0of 0 votes
AnswersWhy Finally block are used in java?
- Rishi Sain July 15, 2011| Report Duplicate | Flag | PURGE
Brainware Software Engineer / Developer Java - 0of 0 votes
AnswersIn C language "Call by value & Call by reference" have occured But do Java support "call by value Call by reference?
- Rishi Sain July 15, 2011| Report Duplicate | Flag | PURGE
Brainware Software Engineer / Developer Java - 0of 0 votes
AnswersIs int i = 2 atomic?
- Anonymous July 03, 2011| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersTypes of exceptions in JAVA
- ds999 June 09, 2011| Report Duplicate | Flag | PURGE
Ebay Front-end Software Engineer Java - 0of 0 votes
AnswersHow inner classes are useful in our project??
- Aresh babu June 03, 2011| Report Duplicate | Flag | PURGE
Huawei Software Engineer / Developer Java - 0of 0 votes
AnswersGiven a number display it in the seven segment display format.
- DNS May 23, 2011| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer Java - 0of 0 votes
Answers2.Explain System.out.println("Hello.");
- farooqui.forever May 08, 2011 in United States
----what is System?
----what is out?
----what is println?
how all they work.| Report Duplicate | Flag | PURGE
CDAC-ACTS Software Engineer / Developer Java - 0of 0 votes
Answers1.Can we use throws along with tr/catch blocks or not?
- farooqui.forever May 08, 2011| Report Duplicate | Flag | PURGE
CDAC-ACTS Software Engineer / Developer Java - 0of 0 votes
AnswersImplement a Memory Pool using ByteBuffer.
- seeksree April 25, 2011
operations: public ByteBuffer allocate(int size) // Creates and returns memory of size 'size' from Memory pool
public ByteBuffer free(ByteBuffer buffer) // frees ByteBuffer referred by buffer from Memory Pool| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 0of 0 votes
AnswersFind the mid of linked list. Sometimes it’s not returning the mid what can be issue. If this class is accessing by multiple threads how to avoid that. If we use Synchronize the performance will be reduced how to tackle that. This class has some other methods as well like addNode, deleteNode, findNode etc.
- JavaJavas April 25, 2011| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersYou have an input file which has one word per line. Write a java
- chandan.here4u April 25, 2011
program which takes this input file and produces an output file satisfying
the following conditions:
a. Each line of output file should have 1 word
b. Output file should contain input file words sorted by frequency
i.e. most frequent words appear at the top and least frequent words at
the bottom
c. For two words having same frequency in the input file, they should
appear sorted alphabetically. for e.g. if A appears thrice and B
appears thrice in input file, output file should have A appearing on
three lines and then B appearing on three lines
d. If an input word is repeated X times, it should appear on X lines
in the output file.
Sample input/output file are as follows:
Input Output
Dog Abhishek
Amar Abhishek
Abhishek Abhishek
Abhishek Amar
Amar Amar
Abhishek Amar
Amar Dog
Boy Dog
Ball Ball
Dog Boy| Report Duplicate | Flag | PURGE
Software Engineer / Developer Java - 0of 0 votes
AnswersImplement a program to represent the all cards of a playing card game. Also write some functions to shuffle it. Also one function to give cards if user asks. Give all implementation details and data structures.
- srb April 22, 2011| Report Duplicate | Flag | PURGE
Software Engineer / Developer Java - 0of 0 votes
AnswersA class inherits Thread. All the methods are synchronized. If two objects are created then which one will get access to the class first?
- davvy April 18, 2011
Can you predict the order? why, why not? Explain wrt thread model.| Report Duplicate | Flag | PURGE
VMWare Inc Software Engineer in Test Java - 0of 0 votes
AnswersWhy is it fine to alter the data members' value of a final class?
- davvy April 18, 2011| Report Duplicate | Flag | PURGE
VMWare Inc Software Engineer in Test Java - 0of 0 votes
AnswersWhat will be the three things you will look into when your java system.application goes slow suddenly. Means one day you notice application is running very slow and till yesterday it was fine, so what three things you will see first or debug first.
- JavaJavas April 12, 2011| Report Duplicate | Flag | PURGE
Java