Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

INDU, BALA

Ranch Hand
+ Follow
since Jun 07, 2001
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 INDU, BALA

All the very best Vidya,

Indu
Congrats Padmaja
Indu
20 years ago
Well Done Rajani

Indu
20 years ago
Hi Vijayan,

Let us go thru your code


Your code works like this
Iter 1 : 1<< 31 = 10000000 00000000 00000000 00000000
i = 5 = 00000000 00000000 00000000 00000101
(1<<31) & 5= 00000000 00000000 00000000 00000000 This exp results line no 8 ie 0

Iter 2 : 1<< 30 = 010000000 00000000 00000000 0000000
i = 5 = 00000000 00000000 00000000 00000101
(1<<30) & 5= 00000000 00000000 00000000 00000000 This exp results line no 8 ie 0
Like this the for loop executes until j becomes 0. Thus the prg is printing the binary value for any given int.
Hope this helps
Indu

[This message has been edited by INDU, BALA (edited August 24, 2001).]
Hi,

We can declare object references for the interface. These
object references can hold any instatnce of the class which
implements that interface. for eg.


Output:
This is from myclass1 10
This is from myclass2 20

The correct version of the method is called thru the obj ref.

Indu

[This message has been edited by INDU, BALA (edited August 23, 2001).]
[This message has been edited by INDU, BALA (edited August 23, 2001).]
Hi Ragu,
For Code no 2 answer is d. You are right.

Indu

Hi Cameron,
Just I have changed Nilsson's code little bit and executed,
go thru this code and its output
code 1:



The output is
j: 0 i: 0
j: 1 i: 0
breaking mainloop

If you replace break mainloop with continue mainloop the output will be like this
j: 0 i: 0
j: 1 i: 0
continuing mainloop
j: 0 i: 1
j: 1 i: 1
continuing mainloop
j: 0 i: 2
j: 1 i: 2
continuing mainloop

Hope this helps
Indu

Hi Sooyun,

For code no 2:

I am getting the error " Sample class cannot be instantiated".
Indu
Hi Asish,
For code 1 :
The out put will be 2.
For code 2 :
The valid methods in the sub class are
void method() { }
void method(int i) { }
Indu
Hi Siobhan,
Can you tell me why no.4 is not correct
I feel it is right. If there is no reference pointing to that object then it is ready for GC.

Indu
No problem. Returntype, accessibility,exception list may vary freely in overloading methods.

Hope this helps