Rajeshwari, Ramamurthi

Greenhorn
+ Follow
since Feb 21, 2001
Merit badge: grant badges
For More
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 Rajeshwari, Ramamurthi

Hi
Do you get questions regarding painting and applets in the exam.
They don't seems to be in the objectives. But most of the mock exams ask question in these topics.
Thanks
Raji
Thanks guys
Sorry I didn't visit javaranch for last few days
So didn't reply you
Raji
Hi
look at the following code

int i =0;
boolean y = false && i==0; //1

Will the expression i==0 be evaluated in statement 1.

I think it will be evaluated first because equality operator has high precedency than && operator

Please clarify my doubt
Thanks
Raji
thanks for your help
so precedency is same for both post-fix and pre-fix operators and associativity is from left to right for both. Am I right?
Raji

Originally posted by Manfred Leonhardt:
Hi,
I will try and walk you through your examples:
no = 1;
ans = ++no + 2*++no;
Compiler does:
ans = (++no) + 2 * (++no)
ans = (1+1) + 2 * (++no) // no = 2 after this
ans = 2 + 2 * (++no)
ans = 2 + 2 * (2+1) // no = 3 after this
ans = 2 + 2 * 3
ans = 2 + 6
ans = 8


Hai
According to 'Programmer's guide to Java certification ' by Khalid A.Mughal (Page 42)

post-fix operator has high precedence than prefix operator and
pre-fix operator associativity is from right- left
But when I run the code given below
I found that both post-fix and pre-fix operator have same precedence and both have left to right associativity

{
int no ;
int ans;
no =1;
ans = ++no + 2*++no;
//associativity expected right-left
//prints 8 expected 7
System.out.println( " ++no + 2*++no = "+ans);

no =1;
ans = ++no*2 + ++no;
//associativity expected right-left
// prints 7 expected 8
System.out.println(" ++no*2 + ++no = "+ans );
no =1;
ans = ++no + no++ *2;
// precedence expected post-fix before prefix
//prints 6 expected 5
System.out.println(" ++no + no++ *2= "+ans );

no =1;
ans = ++no*2 + no++;
//check precedence expected post-fix before prefix
//prints 6 expected 7
System.out.println( " ++no*2 + no++ = "+ans );
}
'Java How to program' by Deital & Deital gives another view . It says (page 144) both have right to left associativity with post-fix having more precedence than prefix.
Can anyone tell me which one is right?
Thanks
Raji
Hi
The accessibility of the members does not affect the accessibility of the class.
This works if you have static inner classe with outer class having all members as private.
In the example given below myInt is the only member variable and it is private. So members of class A are not accessible from outside. But the inner class B can access private variable of class A
public class A{
private int myInt=10;
public B{
public void method1(){
System.out.println(myInt);
}
}
}

I assume inner classes are different from members
correct me if I am wrong
Raji

Originally posted by Zahid, Butt:

" A class in which all the members are declared private cannot be declared public. "
Can someone elaborate on this PLEASE ??? Maybe some code examples ??
Thanks in advance.


Hi
If there are more than one thread waiting to own the monitor of that object, which one will be notified first when notify() method is encountered?
Is it the first thread that called wait() for that monitor or is it arbitarly chosen?
Thanks
Raji