Win a copy of Java by Comparison (eBook) this week in the Java in General forum!

Neha Agarwal

+ Follow
since Mar 12, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Neha Agarwal

This can be done in the following manner

import java.util.HashMap;

public class Test2{

public static void main (String args[])
HashMap hashMap = new HashMap();
hashMap.put(1, "One");
hashMap.put(2, "Two");

9 years ago
As per my knowledge there is no negative marking .


Send the link with a parameter as
<a href="a.jsp?value=a">
<a href="a.jsp?value=b">

and in a.jsp retrieve the parameter using request.getParamter(value).If the value is a then display a part of jsp else the second part
9 years ago

The output is dispalyed correctly .See the explaination below

In public static void main the constructor of class Foo is called at line
Foo f = new Foo(); which prints foo on screen .When we call makeBar method it calls the constructor of class Bar as new Bar() which prints bar on screen and when we call the go method it prints the hi .I hope it answers your question
non-static inner classes keep a reference to the outer class allowing it to access member variables of the outer class
Line 1 is not compiling as it is declared final so its value cannot be modified .
The reason is the way the for loop exceutes
1)Variable is intialized and then comparison is done
eg in this case
i will be initialized to 0 and then compared to value 3 ,since it is less than 3 it goes inside loop and prints value

2)After that it goes to increment part and and increases it by 1 and checks the condition again goes to print statement .So the result in both cases remain same
A error found at compile time is called compile time exception but runt ime exception are those which are indicated at run time .
Unless you're using Java SE 6, you will also need the JavaBeans Activation Framework (JAF) extension that provides the javax.activation package.suggestion is to use version 1.1.1 of JAF, the latest release. JAF is included with Java SE 6
10 years ago
In java language programming, interfaces with no methods are known as marker interfaces. Marker interfaces are Serializable, Clonable, SingleThreadModel, Event listener. Marker Interfaces are implemented by the classes or their super classes in order to add some functionality.

Suppose the interface Clonable is neither implemented by a class named Myclass nor it's any super class, then a call to the method clone() on Myclass's object will give an error. This means, to add this functionality one should implement the Clonable interface. While the Clonable is an empty interface but it provides an important functionality.

To implement the same we have to write the same code as for simple interface as
public class MyClass implements Cloneable {
// ...
public Object clone() { // clone this object
// get a clone of this:
MyClass that= (MyClass)super.clone();
// copy deep clones of reference members from this to that
return that;

I hope this answers your question
10 years ago
String data = "<?xml version= \"1.0\" encoding= \"utf-8 standalone=\"no\" ?> <!-- Race Card Data -->" +
"<!-- Indiana Downs Race: 1 Number of Pools: 12 --> <RaceCardData xmlns:xsi=\"" +
"\" xsi:schemaLocation=\"MECRaceCardData.xsd\"> <DocumentSerialNumber>109089</DocumentSerialNumber> <TimeStamp>2008-01-04 08:03:31" +
"</TimeStamp> <SequenceNumber>1</SequenceNumber> <Event> <EventName>Indiana Downs</EventName> " +
"<EventCode>IJN</EventCode> EventDate>2008-01-04</EventDate> </Event> <Race> <RaceNumber>1</RaceNumber>" +
"<RaceName>N/W $2000 IN LAST 4 STARTS (W/O $40,000 (IS MARES|</RaceName> <NumberOfBettingInterests>4</NumberOfBettingInterests>" +
"<RaceBreed>Unknown</RaceBreed> <Purse>5,800.00</Purse> <Grade /> <Distance>0 Unknown</Distance> <Class>N/A</Class> <TrackSurface>Dirt" +
"</TrackSurface> <SexRestrictions>Unknown</SexRestrictions> <AgeRestrictions>U</AgeRestrictions> <ProjectedPostTime>9:42 AM</ProjectedPostTime>" +
"</Race> </RaceCardData> ";
10 years ago
public class Test {
public static void main(String[] args) {
String str[]={"12","13","345"};
StringBuffer str1 = new StringBuffer();
for (int ii = 0; ii < str.length; ii++)
if(ii==(str.length-1)) {


10 years ago
I tried in jdk1.5 but again I got the compilation error as incomaptible types
Answer D is correct since
First we get the reference of Alpha through which we get the class Elephant and call the soundOff method

Answer C is not correct since
Alpha is not a static class and we cannot use it until we create a object for that class

I hope this answers your question