vkswamy venkatachalam

Greenhorn
+ Follow
since Feb 18, 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 vkswamy venkatachalam

Hi,
U shall be through with IO, operator and assignments.work with all type of primitives and objects and understand the fundamental
and language.
best of luck.
with regards
vkswami
scjp certified.
21 years ago

Hai, Java folks
I cleared the scjp exam sauterday.I Got 79%.thanks for javaranch,MahaAnna,abilash,Jqplus,Margus green ,JohnHunt
to name few.
with regards
vkswami.
21 years ago
Hi,Yadav ,I tried Ur code on both jdk1.2.1 and jdk1.3
it does not compiles.
compiler remarks: imcompatible types
found :void
reqd :boolean
even when compiles with jdk1.1.5
it gives 2 errors.in addition to the above
' ; ' expected
System.out.println("hello")
^
Cameron and Griscti were correct.
regards
vkswami
Hi, jayakumar
Answer c may be wrong.The compiler fails to compile only when
there is 'continue' key word only inside a case.Try the following code.
public class Test1 {
public static void main(String args[]) {
int i = 5;
loop:for(int j=0;j<10;j++){
switch( i ){
case 4:
break;
case 5:
//inserted for knowing what is going inside.
//if U uncomment, donot forget to add { }
//{System.out.println("Inside case 5 : for loop i : "+i);
continue loop;
//if continue without loop and for loop the compiler rejects
default:
System.out.println("Hello World!");
}
System.out.println("end of for loop i : "+i);
}
}
}
the variant of continue works here.so the otion 'c' may be wrong.
Cindy Glass, correct me if I am wrong.
Regards,
vkswami

Hi,Cameron
It is representing a number in binary base.(base 2).
Integer number in java is represented by 32 bits.so when you representing a number say 2 ,it is as follows
0000 0000 0000 0000 0000 0000 0000 0010 = (0 x 1) +(1 x 2) +(0 x 4) ... and so on
when U represents a negative number takes the complement of the the (binary code )number (SAY 2) and add 1
(e.g)
complement of 2 in 32 bits =
1111 1111 1111 1111 1111 1111 1111 1101 +
0000 0000 0000 0000 0000 0000 0000 0001
====================================
1111 1111 1111 1111 1111 1111 1111 1110 = -2
=====================================
back to the Q
the MSB ie the most significant bit represents the sign of the number.
also the f = 15 in decimal base.binary reperesentation of15 =
(binary code) 1111 = (1 x 1) + (1 x 2) +(1 x 4)+(1 x 8)
when 0xf1 is converted to int (32 bits) the sign bit remains the same.
Actually it is -ve number.Ur thouught is correct.
Hope this clear Ur doubt.
Regards,
vkswami.
Hi, Parimala
Q3.Didn't U see the ' ; ' after if condition.This makes the sample running.careful reading.
with regards
vkswami
Hi,Parimala
Did U worked with is code.
I am geting compile time error.so the ans is d.I am using jdk1.3
as invalid method declaration; return type required
public Sample (String string) {
^
1 error
regards
vkswami
Hi, Parimala
didn't U see the ' ; ' after if condition.This makes the sample running.careful reading.
with regards
vkswami
Hi Chunky,
To override a method in the subclass the signature(method name and parameter list) must be identical to the signature of the method in superclass.
1)the return type should be the same as overridden method
2)should not be more private than superclass method
3)any exceptions declared must be the same class as thrown by the superclass or a subclass of the exception
Just changing the return type does leads to overridding.
To Sharma, by overriding U mean to alter the basic behavior the method by oops.Then why are u trying to override two methods not connected in a way.I think it is obstruct to oobs.
regards
vkswami.
Hi,Indika
Reader is a public Abstract class for reading character streams. The only methods that a subclass must implement are read(char[], int, int) and close().
int read()
Read a single character.
int read(char[] cbuf)
Read characters into an array.
abstract int read(char[] cbuf, int off, int len)
Read characters into a portion of an array.
Writer is public abstract class which extends Object
for writing to character streams. The only methods that a subclass must implement are write(char[], int, int), flush(), and close().
void write(char[] cbuf)
Write an array of characters.
abstract void write(char[] cbuf, int off, int len)
Write a portion of an array of characters.
void write(int c)
Write a single character.
void write(String str)
Write a string.
void write(String str, int off, int len)
Write a portion of a string.
In short,read(char[] cbuf, int off, int len) in abstract Reader class and write(char[] cbuf, int off, int len) is absract in abstract writer class.Hope this will clear .
with regds,
vkswami.
Hi,Aruna
since the runtime reference refer to the sub class U are getting subclass write method is excecuted.by changing the ref. to superclass as samith told or U can call super class method asin sample code.
code:
class Process6{
Process6(){
write();
}
void write(){
System.out.println(Thread.activeCount());
}
}
class Test extends Process6{
public static void main(String[] args){
Process6 t = new Test();
//new Process6().write(); method 1
}
//Test(){super.write();} method 2
public void write(){
//super.write(); method 3
System.out.println(Thread.interrupted());
}
}
regrds
vkswami
Hai,Om Sonie
Default constructor will be suppiled by JVM if the class does not define any
constructor of their own.
When the java compiler encounters a situation like this it creates a default
constructor as follows
public class name(){
supper();
}
This constructor only calls the no-arguments constructor of super class.If the
super class does not define such a constructor,a compiler error is generated due to the constructor-chaining rules. If a class does not extend any class Object class constructor speaks here as all the class exends Object class by default.
I hope Ur doubt is cleared.
regards
vkswami
Hi,Paratiti
If the shifting is grater than the bits the no is sifted by its modulus
e.g 234 >> 34 .
it is left shifted by 2 (34%32)
regards
vkswami
Hi,Bala Krisna
U can compare this as follows
class Test1{
void testDouble(){
double d=999.99;
double dd = 999.99;
// or
//U can get a value by input and change it to double
//check with API Double methods.
if(d==999.99)
System.out.println("I am equal and double value");
else
System.out.println(" I am not equal");
}
public static void main(String[]args){
Test1 t= new Test1();
t.testDouble();
}
}
regrds
vkswami
Both situation volountrily gives up it lock on the object and goes to waiting state.
regrds
vkswami