Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

varinder mahajan

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

Recent posts by varinder mahajan

quote: class A implements Cloneable
{
int age;
A(int age)
{
this.age=age;
}
public int getage()
{
return age;
}
public Object clone()
{
A aa=null;
try
{
aa=(A)super.clone();

}
catch(Exception e)
{

}
finally
{
return aa;
}
}
public static void main(String str[])
{

A a1=new A(10);
A a2=(A)a1.clone();
System.out.println(a1.getage()+"==="+a2.getage());
System.out.println(a1.equals(a2));

}
}



output :

C:\>javac A.java
C:\>java A
10===10
false

expected output:

C:\>javac A.java
C:\>java A
10===10
true
13 years ago
if it is not in the objective ..could any one explane it...

class A implements Cloneable
{
int age;
A(int age)
{
this.age=age;
}
public int getage()
{
return age;
}
public Object clone()
{
A aa=null;
try
{
aa=(A)super.clone();

}
catch(Exception e)
{

}
finally
{
return aa;
}
}
public static void main(String str[])
{

A a1=new A(10);
A a2=(A)a1.clone();
System.out.println(a1.getage()+"==="+a2.getage());
System.out.println(a1.equals(a2));

}
}



output :

C:\>javac A.java
C:\>java A
10===10
false

expected output:

C:\>javac A.java
C:\>java A
10===10
true
can anyone expain me the keyword super in detain.. ?

import java.util.*;
class Demo
{
public static void main( String args[] )
{
PriorityQueue<Integer> p=new PriorityQueue<Integer>();
p.offer(1);
p.offer(1);
p.offer(1);
System.out.println("size:"+p.size());

for(int i : p)
{
System.out.println("poll");
p.poll();
System.out.println("size:"+p.size());
}
System.out.println("added two elements");
p.offer(1);
p.offer(1);
System.out.println("size:"+p.size());
for(int i : p)
{
System.out.println("peek");
p.peek();
System.out.println("size:"+p.size());
}
}
}

Please help, i am unable to understand . where is the problem

import java.util.*;
class Demo
{
public static void main( String args[] )
{
PriorityQueue<Integer> p=new PriorityQueue<Integer>();
p.offer(1);
p.offer(1);
p.offer(1);
System.out.println("size:"+p.size());

for(int i )
{
System.out.println("poll");
p.poll();
System.out.println("size:"+p.size());
}
System.out.println("added two elements");
p.offer(1);
p.offer(1);
System.out.println("size:"+p.size());
for(int i )
{
System.out.println("peek");
p.peek();
System.out.println("size:"+p.size());
}
}
}




C:\>java Demo
size:3
poll
size:2
Exception in thread "main" java.util.ConcurrentModificationException

This is the output what is the problem
at java.util.PriorityQueue$Itr.next(Unknown Source)
at Demo.main(Demo.java:12)
super can be used only with ? like <? super Apple> in method calls.
we can not use class Pie<T super Apple>{

is it right.
[ September 01, 2008: Message edited by: varinder mahajan ]
String s=new String("abc");
some pople say 2 ? is it right
i am really confused,still we are in a fix....
some people say 3 and some say 4...
String s1="abc";
String s2="xyz";
String s3=new String("abcd");
how many object will get created?
Some peole say 4 objects..is it right
Are variables defined inside a constructor instance or local?

Hi i have doubt in matching exactly the STATEMENTS and their COLLECTION TYPES.

Given the Statements :

1. Allows access to elements by their integer index
2. defines the method: Vgey(Object Key)
3. is designed for hacking elements prior to processing.
4. Contains no pair of elements e1 and e2 such that e1.equals(e2).

Collection Types :

1.Java.util.Map
2.Java.util.Set
3.Java.util.List
4.Java.util.Ques

I am bit confused...please need a bit more explaination...