Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!

vijay gardiner

Greenhorn
+ Follow
since Jan 26, 2002
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 vijay gardiner

thanx!
that helps!
Vijay
17 years ago
Hi,
Yeah you can do that, but the vice versa would end in compilation error.
If I'm right in interpreting ur doubt, here goes my example :
class A {
public void Test() throws IOException { }
}
class B extends A {
public void Test() {}
}
In the above example, Test() with no exception thrown overrides the Test() which throws exception, which is perfectly alright.
Vijay
This
17 years ago
x=1;
x << 29 yields 536870912, whose binary representation is all zeroes except '1' in the 30th higher order bit.
x << 30 yields 1073741824, whose binary representation is all zeroes except '1' in the 31th higher order bit.
What happens when x << 31 ?? Can anyone explain please in detail with the regd to the bits in binary form ??
Thanx,
Vijay
17 years ago
Are exams conducted on sat/sun ??
vijay
17 years ago
thanx! that was useful!
17 years ago
I've a program like :
public class Boxdemo {
int x = 10;
public static void main ( String args[] ) {
Boxdemo nt = new Boxdemo() ;
nt.x = 20;
System.out.println ("nt.x" + nt.x);
}
}
This program passes the compilation, but i've another program like :
public class Boxdemo {
int x = 10;
public static void main ( String args[] ) {
Boxdemo nt = new Boxdemo() ;
Boxdemo.x = 20;
System.out.println ("Boxdemo.x" + Boxdemo.x);
}
}
But this program fails in compilation : saying non-static variable cannot be accessed in a static context.
If the second program fails, I thought the first program also should fail, b'cos I'm accessing the same variable 'x' under the static main method().
Can anyone why i get the error message?
17 years ago
Congrats!
I'm planning to take the exam shortly.....I'm planning to take the exam within the next 20 days I leave for India. Is it possible? I mean, is there any time limit before after the regsitration before I take the exam?
Can I take the exams on sat/sundays without bunking my work ?
Aslesh
17 years ago
Hi,
I'm planning to take the SCJP exam with the next month. Can anyone explain some of my doubts like :
1.Today is Feb 15th, so when can i take the exam at the earliest?? i.e., can i take the exam on Feb 20th if possible??
2.Are SCJP exams conducted on saturdays and sundays?
3.Are there any discount coupons I can get for the exam fee of 150.00 ??
Thanx,
Vijay
17 years ago
Hi,
As I'm a beginner, I'm not still clear with ur explaination.....you've told "The second program attempts to access the instance variable 'x' as a static variable"
I don't understand the part "static variable" in ur explaination. A\as I'm accessing the instance variable x directly by the class name, do you mean that java will interpret that as a 'static variable', and the how come, if i access the same variable x using an instance of that class "nt", java doesn't say any error messages??
Please, can you explain??
Vijay
17 years ago
I've a program like :
public class Boxdemo {
int x = 10;
public static void main ( String args[] ) {
Boxdemo nt = new Boxdemo() ;
nt.x = 20;
System.out.println ("nt.x" + nt.x);
Boxdemo nt1 = new Boxdemo();
nt1.x = 30;
System.out.println ("nt.x" + nt.x);
System.out.println ("nt1.x" + nt1.x);
}
}
this program passes the compilation, but i've another program like :
public class Boxdemo {
int x = 10;
public static void main ( String args[] ) {
Boxdemo nt = new Boxdemo() ;
Boxdemo.x = 20;
System.out.println ("nt.x" + nt.x);
Boxdemo nt1 = new Boxdemo();
nt1.x = 30;
System.out.println ("nt.x" + nt.x);
System.out.println ("nt1.x" + nt1.x);
}
}
But this program fails in compilation : saying not-static variable cannot be accessed in a static context.
If the second program fails, I thought the first program also should fail, b'cos I'm accessing the same variable 'x' under the static main method().
Can anyone why i get the error message?
Thanx,
Vijay
17 years ago
I've a program A :
class A {
static void demoproc() {
try {
System.out.println("inside demoproc: ");
throw new RuntimeException("demo");
} finally {System.out.println("finally in A "); }
}
public static void main(String args[]){
try {
demoproc();
} catch(RuntimeException e) {
System.out.println("caught ");
}
}
}

I've program B like :
class B {
static void demoproc() {
try {
System.out.println("inside demoproc: ");
throw new IllegalAccessException("demo");
} finally {System.out.println("finally in A "); }
}
public static void main(String args[]){
try {
demoproc();
} catch(IllegalAccessException e) {
System.out.println("caught ");
}
}
}
The program "A" works, but "B" end in compilation errors, the only difference between the above two is "RuntimeException" and "IllegalAccessException", why is that? Could anyone explain that please??
Vijay
17 years ago
Hi,
I've a code like :
/* this is a simple program */
class test {
int z[];
z = new int[5];
}
class Example {
public static void main(String args[]) {
//dummy class calling the main method
}
}
When i compile the above program I get errors at the memory allocation statement :
z = new int[5];
I don't find anything wrong with the array declaration. Can anyone tell me why is that ?
Thanx,
Vijay
17 years ago
Hi,
I've a pgm like :
class Box {
int i=10;
int j=20;
Box(int i, int j){
i = i;
j = j;
}
int sqr() {
return i*j;
}
}
class const1 {
public static void main(String args[]) {
Box a = new Box(2,3);
System.out.println(a.sqr());
}
}
In the above program, I understood that when the constructor Box was called with the arguments (2,3), then i thought that those values would be passed to the constructor and "the class variables" i and j would be assigned to 2 and 3 resp., so I expected the result to be 2 * 3 = 6, but I get the result 10 * 20 = 200.
Why is that ?
But when i change the variable names in constructor code i1 and j1 like :
Box(int i1, int j1){
i = i1;
j = j1;
}
Then i get the result as 2 * 3 = 6.
Can anyone explain why such a difference in this? and how java interprets the variables internally.
Thanx,
Vijay
17 years ago
Hi,
I've a pgm like :
class Example {
public static void main(String args[]) {
int a[][] = new int[5][5];
a[0][] = {1,2,3,4,5};
for (int i=0,j=0;i<5;++i,++j)
System.out.println(a[i][j]);
}
}
when i compile I get an illegal start of expression.....why is that?
I've declared int a[][] = new int [5][5]; (a 2 dimensional array)
then i've initialised the first row of the array as {1,2,3,4,5}, i don't understand why there is any error in the above statment.
Could anyone please clarify.
Thanx,
Vijay
17 years ago