naveen sahu

Ranch Hand
+ Follow
since Nov 15, 2000
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 naveen sahu

you proved that hard work pays.
19 years ago

Originally posted by Ajith Kallambella:

The break statement may not serve as an alternative to the return statement since it ( former ) can be used only in loop-structures.


Ajith
but i think break can be used any where there is a possibility of creating a local scope. whether it may be a if-else or swith or try-catch etc construct.
here is supporting code.

<pre>
class Test {
public static void main(String arg[]) {
int i=8;
label1:
if (i>3)
{
System.out.println("label allowed");
break label1;
}
label2:
switch(i)
{
case 1: System.out.println("again allowed");
break label2;
}

label3:
try {
System.out.println("again allowed");
break label3;
}
catch(RuntimeException re) {}
}
}
</pre>

Originally posted by alpa urja:
Thanks Latha
but in one of the sites(I don't remember the site name),they mentioned Extern as a keyword in JAVA......
<pre> that is dut to alpa-gyan </pre>
alpa-urja


it should be b & d ( i think)

Originally posted by Jane Griscti:
Hi Nasir,
The last line is 3 vs 2 because the superclass initializer is called before the subclass initializer or constructors.
<pre>
the line you have written is true in conclusion but that associated reason is wrong.not have any link with explaination.
</pre>
At that point in the compile the superclass is totally unaware of the fields which exist in the the subclass.
<pre> true </pre>
The field 'x' in the superclass is assigned the value 3; not the field 'x' in the subclass.
<pre>
that is absolutely wrong . </pre>
<pre>
in the original code the variable x is declared in both of the classes. so second one hides first one.and rest of all done due to flow of execution. i can explain in detail but i don't want to
west my valuable time in this particular thread.better i searched some sesnsible thread.
</pre>


Originally posted by Rosemol Thanjappan:
Hi,
Thankyou for the information.
It will be great help to get that clue.

Does any Deprecated ones since Oct.4?
Eg:-
In the above question stop(),suspend() are deprecated.

Thanking you
Rosemol.


absolutely not ! don't worry
19 years ago

Originally posted by Nasir Khan:

As output shows I assume that order of code execution is
=> static variables initialization and then static initializer block execution in super class. <pre> slightly missed </pre>
=> static variables initialization and then static initializer block execution in sub class. <pre> slightly missed </pre>
=> instance initializer blocks execution in super and then in sub class <pre> anah </pre>
The way I think about the code execution is correct...or something else goes on here..?
Also I think last line of output should be 2 instead of 3 because x just has been assigned a value of 2 in super's instance
initializer block...



[This message has been edited by naveen sahu (edited December 28, 2000).]

Originally posted by Rajpal Kandhari:
Hello,
Wow Again for me Java is a funny Language.



in that perticular class a lot of amount of code is redundant/unnecessary/worthless.
1) setArea method what is available in given class is absolutely westage. because if you are not having no args constructor in both of the class , then what is the need for setArea method.in the original code "writer/programmer/developer" wants to set the width & length through that method.that doesn't worth. instead of this if width & length variable declared as public & set explicitly , i think that will be much better. as available in java.awt.Point class.as available in java.awt.Dimension class etc.
2) the variable area & volume is meaningless. what are they doing there i can't understand.
3) the constructor of every class should be used as a initializer for the variables, not for doing any calculation or method call( if possible) because it's a bad habbit.
(like rectangle class constructor calling setArea in original code & box class constructor doing volume calculation).
and in last if java is funny so what are you doing here. without having the knowledge of java's "J" and "O" of oop's how can you think that you can analyse a given code of java. without knowing about flow control of code execution how can you decide that which method calling or variable shifting may cause effect on which portion of code.think about it !
and in the very last do you really know what was the writer of originally given code wants to do ? and which difficulty he feel ? and what he is asking in his post?
according to me what i know about java & oops the original code should be re-written as follows.
<pre>
class Rectangle{
int width, length ;
Rectangle(int w , int l)
{
width = w;
length = l;
}
int getDimension(){return width*length;}
}
class Box extends Rectangle {
int height ;
Box(int w , int l , int h)
{
super(w,l);
height = h;
}
int getDimension() {return height*length*width; }
}
class test5
{
public static void main(String[] args)
{
Box b = new Box(5,5,5);
System.out.println(b.getDimension());
}
}
</pre>
i think i can do it without calling any method(over head) as bill did. this can be done by just copying/shifting two lines of code from to setArea method to Rectangle constructor.
have a look....
<pre>
class Rectangle{
int width, length , area;
Rectangle(int w , int l)
{
width = w;
length = l;
setArea(w,l);
}
void setArea(int w , int l)
{
width = w;
length = l;
area = w * l;
}
int getDimension(){return area;}
}
class Box extends Rectangle {
int height , volume;
Box(int w , int l , int h)
{
super(w,l);
height = w;
volume = height * width * length;
}
void setArea(int w ,int l)
{
volume = area * height;
}
int getDimension() {return volume; }
}
class t
{
public static void main(String[] args)
{
Box b = new Box(5,5,5);
System.out.println(b.getDimension());
}
}
</pre>

some heavy modifications are also necessary in the original code.
it may be difference of way of thinking . (may be )
IMO ,in the under going process from programmer to developer , a programmer get fully developed (mentally & logically both). that's why they were not having intrust in kid's show. giving thanks to many peoples like notes i think are funny. (they have not won the oscar).
and to showing the respect to a person by this way is not the only way. basically for the whole world i am a "atheist", because i won't like to go to church , temple, masque etc. i am not intrusted in all that drama's. i believe in god heartedly. i mean it.

refer following link http://www.javaranch.com/ubb/Forum25/HTML/000181.html
in this link there is a java developer talking to some one. and i think that man
Vladan Radovanovic is really a developer.
probabely people agree with me.

[This message has been edited by naveen sahu (edited December 20, 2000).]

Originally posted by Nasir Khan:
yes naveen ,all components inherit everything from Component class.A Label can generate MouseMotionEvent etc.


oh my god ! you again through a hydrogen bomb named "MouseMotionEvent" . i think that event is soloely written by you . please send me your copy of java api & jdk also . i think i have to update my knowledge also.
and last thing about labels ....
refer RHE
chapter no. 11
chapter name . Components.
page no. 322
line no. 18 to 19.
which says that "The Simplest AWT component is the label. Labels do not respond to user input, and they do not send out any events."
the above statement is from RHE indian edition.
i have not worked on the strategy named "Permutation & Combination" . because for this strategy my whole life period is too short. and i do not believe in "reincarnation"

Originally posted by Nasir Khan:

Though CheckBoxMenuItem generates ItemEvent but it should generate ActionEvent as well b/c addActionListener method is
inherited from its super class MenuItem...


brilliant logic ! its really amazing . keep it up.
with due respect to above theory Label should generate FocusEvent, KeyEvent, MouseEvent. because component class
having addXXXListener method of corresponding events.
and Label is the subclass of component.
rest of all you understand easily.

Originally posted by Amar Das:
I was just testing the installation of java on my machine. I wrote the following program and saved it as Hello.java. Then I compiled it using javac Hello.java. It compiles fine. But when I try to run it using java Hello I got the following error messageException in thread "main" java.lang.NoClassDefFoundError: Hello
My code sample for Hello


after compilling see the directory listing of your current directory in which your class hello existing.
read the name of that class carefully with propercase (upper/lower) and then execute command
java "your class name wihout extension"
every thing will be fine.
this is the mistake due to uppercase lowercase mistake & nothing else.
check name of the .class file created after compillation and then execute above command