# Satheesh Kumar

Greenhorn
since Nov 21, 2000
Cows and Likes
Cows
0
In last 30 days
0
Total given
0
Likes
0
0
Total given
0
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

## Recent posts by Satheesh Kumar

Hai
I have just now finished my Certificate Exam with 75%.
I am really thankful for all the officials, in their effort to answer each and every doubt raised in this site.
I declare it proudly that without JAVARANCH I really could not
have accomplished this Successfully.
Thanks a lot for all the participants too.
satheesh
18 years ago
Thanks bob for ur detail explanation
now I got it..,
satheesh
18 years ago
weigang and carl thanks for ur valuable infomation
Those explanation really helped me a lot
satheesh
18 years ago
Hello
Can somebody show light on these o/ps what is the
ultimate effect when a negative no is used in the
shift operations...?
System.out.println("7 >> -1 = "+ (7 >> -1));
System.out.println("7 << -1 = "+ (7 << -1));<br /> o/p is 7 >> -1 = 0 & 7 << -1 = -2147483648<br /> System.out.println("8 >> -1 = "+ (8 >> -1));
System.out.println("8 << -1 = "+ (8 << -1));<br /> o/p is 8 >> -1 = 0 & 8 << -1 = 0 <br /> System.out.println("2 >> -1 = "+ (2 >> -1));
System.out.println("2 << -1 = "+ (2 << -1));<br /> 0/p is 2 >> -1 = 0 & 2 << -1 = 0<br /> System.out.println("3 >> -1 = "+ (3 >> -1));
System.out.println("3 << -1 = "+ (3 << -1));
o/p is 3 >> -1 = 0 & 3 << -1 = -2147483648
satheesh
18 years ago
I reallly could not understand what is given in the book when I read it, could u pls explain to me in brief
18 years ago
Check out this example from "sandeep mock exam"
class MyClass
{
public static void main(String []args)
{
final int i = 100;
byte b = i;
System.out.println("i ="+b);
}
}
ans : o/p i =100
BUT
class MyClass
{
public static void main(String []args)
{
int i = 100;
byte b = i;......(1)
System.out.println(b);
}
}
I get a compiler error as Incompatible type declaration, so when I cast line (1) as byte b = (byte)i; it works fine with o/p 100
why is this strange behaviour with " final keyword"?, I am confused.
can somebody clear my doubt?
satheesh
18 years ago
Questions from khalid, I am not sure of the answere can somebody
explain to me
1.Given that a static method doIt() in a class Work represents work to be done, what block of code will succeed in starting a new thread that will do the work?
CODE BLOCK A:
Runnable r = new Runnable() {
public void run() {
Work.doIt();
}
};
t.start();
CODE BLOCK B:
public void start() {
Work.doIt();
}
};
t.start();
CODE BLOCK C:
Runnable r = new Runnable() {
public void run() {
Work.doIt();
}
};
r.start();
CODE BLOCK D:
t.start();
CODE BLOCK E:
Runnable t = new Runnable() {
public void run() {
Work.doIt();
}
};
t.run();
////
2.Which method implementations will write the given string to a file named "file", using UTF8 encoding?
IMPLEMENTATION A:
public void write(String msg) throws IOException {
FileWriter fw = new FileWriter(new File("file"));
fw.write(msg);
fw.close();
}
IMPLEMENTATION B:
public void write(String msg) throws IOException {
OutputStreamWriter osw =
new OutputStreamWriter(new FileOutputStream("file"), "UTF8");
osw.write(msg);
osw.close();
}
IMPLEMENTATION C:
public void write(String msg) throws IOException {
FileWriter fw = new FileWriter(new File("file"));
fw.setEncoding("UTF8");
fw.write(msg);
fw.close();
}
IMPLEMENTATION D:
public void write(String msg) throws IOException {
FilterWriter fw = FilterWriter(new FileWriter("file"), "UTF8");
fw.write(msg);
fw.close();
}
IMPLEMENTATION E:
public void write(String msg) throws IOException {
OutputStreamWriter osw = new OutputStreamWriter(
new OutputStream(new File("file")), "UTF8"
);
osw.write(msg);
osw.close();
}

18 years ago
Thanks Jane for ur explanation, now I understood the way it works
satheesh
18 years ago
public class Test {
public static void main(String args[]) {
StringBuffer a = new StringBuffer("One");
StringBuffer b = new StringBuffer("Two");
Test.swap(a,b);
System.out.println("a = "+ a +" & b = " + b);
}
static void swap (StringBuffer a, StringBuffer b) {
a.append(" more");
b=a;
}
}
///ans is " a = one more & b = two "
can somebody throw light on the strange behaviour of the
"append()"
I expected the answer to be " one and two " but why this res?
satheesh

18 years ago
Hi,
Here are some questions from ibm mock exam can somebody help me to find the answers
1. An applet is more restrictive than an application in the following ways: (2 choices)

a) An applet may not perform local disk I/O.
b) An applet may not connect with any server except the
server where the applet was loaded from
c) An applet can change the CODEBASE
d) An applet cannot call the update() method directly
2) ThreadGroup class instances: (2 choices)
a) Allow threads to be manipulated as a group
b) Provide support for ThreadDeath listeners
d) Must contain threads of the same type
3) Primitive type wrapper classes: (3 choices)
a) Allow primitive types to behave as reference types
primitive numeric types
c) Provide string parsing and conversion methods
d) Provide arithmetic operators such as plus and minus
e) Are provided for all primitive types, including void

4) The following are true of Java character-oriented streams:
(2 choices).
a) They provide support for character conversion between
Unicode and ASCII
b) They all implement the CharacterStream Interface
c) They inherit from either the Reader or Writer abstract
classes
d) They are restricted to 2^16 (2 raised to power of 16) in
length
5) Which of the following method pairs are best used for controlling thread communication?
a) stop() and resume()
b) wait() and notify()
d) run() and destroy()
6)if(a) {x=y;} else{x=z;} can otherwise be writtern as
a) a=x?x=y:x=z;
b) x=a?x=y:x=z;
c) x=a?y:z;
d) a=x?y:z;
18 years ago
Thanks Bill and Rajiv
I did not mean to confuse people, but my question was to get an answer for "is a" relation
If I had done so.., I am extremely sorry..,
Thanks for the explanation, now I am clear with the ans

Originally posted by Satheesh Kumar:
Hai
I found this question in "sun site " for "has a " relationship..,
now can anyody help me out in this question

Which two demonstrate a "is a" relationship?
a. public interface Person{ }
public class Employee extends Person{ }
b. public interface Shape{ }
public interface Rectangle extends Shape{ }
c. public interface Colorable{ }
public class Shape implements Colorable{ }
d. public class Species{ }
public class Animal{private Species species;}
e. interface Component{ }
class Container implements Component{
private Component[] children;
}

18 years ago
Hai
I found this question in "sun site " for "has a " relationship..,
now can anyody help me out in this question

Which two demonstrate a "is a" relationship?
a. public interface Person{ }
public class Employee extends Person{ }
b. public interface Shape{ }
public interface Rectangle extends Shape{ }
c. public interface Colorable{ }
public class Shape implements Colorable{ }
d. public class Species{ }
public class Animal{private Species species;}
e. interface Component{ }
class Container implements Component{
private Component[] children;
}
18 years ago
Sivram
All the other answers except d given by Aruna will be applicable even if "class C extends A "
d) z= (C)y;
// gives a Compiler error "Invalid Cast from B to C"
This is because any two Subclass (from a Single Parent) cannot communicate, We cannot "Cast" them.
I think now ur doubt is cleared
satheesh

Originally posted by Sivaram Ghorakavi:
Q20) Which statements, when inserted at the indicated position in the following code, will cause a runtime exception when attempting to run the program??
class A {}
class B extends A{}
class C extends C{}
public class Q3ae4
{
public static void main(String args[])
{
A x = new A();
B y = new B();
C z = new C();
// insert statment here
}
}
a) x = y;
b) z = x;
c) y = (B)x;
d) z = (C)y;
e) y = (A)y;
BOL

18 years ago

Hi,
I am new to java , I have some basic doubts can somebody clear it for me..., I am studying java by my own that is I am streching my hand for help..., I found this site to be the apt place where people are ready to help me out.., ( I am sorry though I knew this is basic for u people who are preparing for programmer certification..,
1. How will u DEBUG java programs.., I meant line by line debuging as we do in c/c++..,(detailed pls..,).., this is to see the flow of the pgm, and the corresponding values in each line
2. how will u run this code in the
import java.awt.*;
public class Butt extends Frame{
public static void main(String argv[]){
Butt MyBut=new Butt();
}
Butt(){
Button HelloBut=new Button("Hello");
Button ByeBut=new Button("Bye");