aditi mudholkar

Greenhorn
+ Follow
since Feb 26, 2007
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 aditi mudholkar

Thnx Quintin...

but i dint understand
String s1="hello";
String s2="hello";
String s3= new String("hello");
if(s1 == s2)System.out.println("s1 referencing same string as s2");// returns true

why is the above code returning true?s1 and s2 are referencing different memory locations rite? and as you said == will return true only when they are referencing in the same memory locations.
Integer i1=1000;
Integer i2=1000;
if(i1 != i2)System.out.println("different");
if(i1.equals(i2))System.out.println("equal");

Output::::
different
equal


Integer i3=10;
Integer i4=10;
if(i1 == i2)System.out.println("same");
if(i1.equals(i2))System.out.println("equal");

Output::::
same
equal



Could someone please explain the difference??? != and == really confusing me.!= tells they are different objects and == says they are the same..???
question 1::::

class maybe{
public static void main(String []args)
{boolean b1=true;
boolean b2=false;
System.out.print(!false ^ false);
System.out.print(" " + (!b1 & (b2=true)));
System.out.println(" " + (b2 ^ b1));
}}

doubt::: in the 3rd println how can the output be false?in fact what the ^ operator does is check for only one true in the expression and it gets it from the b1 variable...?

question 2::::also im still not at clear with the & and | operators.

question 3:::could you please explain me the following code

class titanic{
public static void main(String []args){
Boolean b1=true;
Boolean b2=false;
Boolean b3=true;
if((b1 & b2) | (b2 & b3) & b3)
System.out.println("alpha");
if((b1=false) | (b1 & b3) | (b1 | b2))
System.out.println("beta");
}}
the output comes out to be nothing at all. please explain it step by step?

THANKS!!
Doubt 1:

1.class programmer{
2.programmer debug(){return this;}
3.}
4.class SCJP extends programmer{
5.//insert code here
6.}

Question: which inserted at line 5 will compile?

one of the answers to the question is
programmer debug(){return this;}

did not understand how did that happen as there is no overriding or overloading taking place.

Doubt 2:

1.class dog{}
2.class beagle extends dog{}
3.class kennel{
4.public static void main(String []args){
5.beagle b1=new beagle();
6.dog dog1=new dog();
7.dog dog2=b1;
8.//insert code here
9.}}

question:which inserted at line 8 will compile?
the answer to tis question was
beagle b2=(beagle)dog1;
beagle b3=(beagle)dog2;

did not understand this.Please help!!

Doubt 3:
The concept of var-arg is also not clear. i know it should come at the last in the method's argument.But could you please explain with an example.

Thanks.
yes i know the syntax. but the code like

void display(int num,string ....args)
what does the .... imply???
hi.
i have not been able to understand the var-args syntax and in what way should the var arg be the last of a method's argument.
could you explain with an example.
thanks
hi all...
i have just started studying for SCJP since last week and would like to know how to go about preparing for the exam.i am studying from Kathy Sierra and Bert Bates.so any pointers from you?also from when should i start taking the mocks?are there any mocks topic or chapter wise??