Chamya Pehalvan

Greenhorn
+ Follow
since Jul 10, 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 Chamya Pehalvan

I understand what you are trying to say but read the foll.
say you have a file called "check.java" in a package "Java2"
you have your Java2 directory in C:drive directly -ie -
C:\Java2
Now if you set your classpath to c:\Java2 and compile your program:
javac check.java
after setting your path to the bin directory then this should cause no problems as it had caused me no errors before for the pst 6 months. What I am trying to do is the same as what you have said - just that you are setting your classpath just upto C: drive and compiling your program from your parent directory - ie - from Java2.
Thanks for your help though Srini

Originally posted by vasansrini:
The error is due to the package statement.
Suggestions:
-----------
1. cd \
2. c:\>set classpath=c:\
3. c:\>java Neha.Check2
My last suggestion would be, spend some time on reading how to pacakage your classes.
If you got time, please post it here.
- Srini.

[This message has been edited by vasansrini (edited July 30, 2000).]


Hi vasansrini,
I tried to set the path also running it the way you suggested and it still does not work!!! The code is as follows:
package Neha;
public class Check2
{
public static void main(String args[])
{
System.out.println("WELCOME");
}//main method......
}//class Check2

Originally posted by vasansrini:
Run the program like this
> java -cp C:\Neha Check2
or you could set up the class path like this
> set classpath=C:\Neha
> java Check2
If it does not work, please post your code here.
[This message has been edited by vasansrini (edited July 30, 2000).]


HI Aparanji,
I already have my file saved as Check2.java, yet I get this error for all my earlier files as well which I had written a year back!
Please somebody help!

Originally posted by Aparanji Raju:
Hi,
Check out if you have saved the given file as Check2.java and not just Check2 .The error you have named usually arises when u have gone wrong with the naming conventions of the file wherein you place your program.
Hope this helps.
Aparanji.


Hi Udayan,
As per the code....the loop should only run once as there is no condition for the loop to restart(-ie-no increments) and hence after executing once it will exit out if no statements after that.

Originally posted by Udayan:
Consider the code below
int i=0,j=0;
while(i+j<20)
{
System.out.println(i+j);
j+=i;
}
This loop executes JUST ONCE(??) when it should be an infinite loop.There is an abrupt completion of the loop.I think the problem is in the j+=i; statement 'cause removing it results in an infinite loop.BUT WHAT IS THE PROBLEM??



I am studying for my Java certification exams & am trying to write these 1 line programs & compile & run them, Before I never had any problems running them, but, now after I compile them they dont just run & give me an error as follows:
Exception in thread "main" NoClassDefFoundError:Check2
Where Check2 is the name of my file
my jdk1.2.2 is in c:\ and my bin is in jdk1.2.2 & my java & javac application are in the bin directory
so
c:\jdk1.2.2\bin\java & c:\jdk1.2.2\bin\javac exists
& c:\Neha\Check2 exists
c:\set PATH=%PATH%;c:\jdk1.2.2\bin is the path set
Up until now that is how I Have been running my programs but now I get these errors. It is very irritating to know that now since u have to study for your exams I have to face these errors.
Please help me out with my errors........
hi Tian,
1. A = true as equals() method determines if they return the same object - the return value can be True/False. So in my guess
C is not true
2. == operator checks to see if the sequence of the content of the 2 ojects is the same.Hence I would say that B is true.

Originally posted by tian Lau:
Which of the following statements are true?
A. The equals() method determines if reference values refer to the same object.
B. The == operator determines if the contents and type of two separate objects match.
C. The equals() method returns true only when the contents of two objects match.
D. The class File overrides equals() to return true if the contents and type of two separate objects match.


Thanks Sdev for all your help... but what if u have to shift large #'s by large #'s...how would we evaluate the results then!
Thanks in advance

Originally posted by sdev:

May be I can help for this problem as for as I know
If this is wrong please reply.
* Shifting -1 to the right always results in -1
Shifting -1 to the left always results in -1

* Shifting 1 right 31 bits(1>>31) results in 0
Shifting 1 left 31 bits (1<<31) results in -value<br /> <br /> * Shifting -1 with unisigned right shift(-1>>>1)
results in positive value

* Shifting 1 with unsigned right shift(1>>>1)
results in positive value (0)


Hi Madhav,
I do not mean to be rude when I am asking these questions as I have a big list of questions to ask & am just typing away my queries....I do not know how this works & am just confused & was hoping someone would help me sort out my fundas

Originally posted by Madhav Lakkapragada:

Chamya:
so what do you think? While posting a qstn, please let us know what you think. I bet there are millions out there who
could possibly answer this, but what matters to you is
"do you understand the concept" ?
I don't mean to be harsh, but it would help me explain better
only if I know what you think. Hope take my suggestion
in the right sense.

Regds.
- satya


I do not know the answere to the given code & hence my question to whoever can help me solve it!

Originally posted by Chamya Pehalvan:
Which statements @ the O/P of the foll. are true?
public class Logic
{
public static void main(String args[])
{
int i = 0;
int j = 0;

boolean t = true;
boolean r;
r = (t & 0<(i+=1));
r = (t && 0<(i+=2));
r = (t | 0<(j+=1));
r = (t | | 0<(j+=2));

System.out.println(i+""+j);
}//main
}//class
1. 1st digit printed is 1
2. 1st digit printed is 2
3. 1st digit printed is 3
4. 2nd digit printed is 1
5. 2nd digit printed is 2
6. 2nd digit printed is 3


Which statements are true?
int a .....(1)
static int a;........(2)
int f() {return a;}........(3)
static int f() {return a;}........(4)
(1)& (3) cannot occur in the same class definition
(2)& (4) cannot occur in the same class definition
(1)& (4) cannot occur in the same class definition
(2)& (3) cannot occur in the same class definition

22 years ago
class mya
{
int a;
boolean b;
String s;
public mya(int x, boolean y, String z)
{
String s;
this.a = x;
s = z;
methoda();
}//constructor mya
void methoda()
{
System.out.println(this);.......(What does the this signify over here???)
}//methoda
}//class
Which statements @ the O/P of the foll. are true?
public class Logic
{
public static void main(String args[])
{
int i = 0;
int j = 0;

boolean t = true;
boolean r;
r = (t & 0<(i+=1));
r = (t && 0<(i+=2));
r = (t | 0<(j+=1));
r = (t | | 0<(j+=2));

System.out.println(i+""+j);
}//main
}//class
1. 1st digit printed is 1
2. 1st digit printed is 2
3. 1st digit printed is 3
4. 2nd digit printed is 1
5. 2nd digit printed is 2
6. 2nd digit printed is 3

What would be printed during execution of the foll. program?
public class Myclass
{
public static void main(String args[])
{
test(1<<32,"1<<32");
test(1<<31,"1<<31");
test(1<<30,"1<<30");
test(1, "1" );
test(0, "0" );
test(-1, "-1" );
}//main
public static void test(int i, String exp)
{
if ((i>>1)!=(i>>>1))
System.out.println(exp);
}//test method..
}//class
Select all valid answeres:
"1<<32"
"1<<31"
"1<<30"
"1"
"0"
"-1"

Hi Again,
I seem to be having all the difficulties in the world understanding my concepts. In the exams we are not provided with all the time in the world so how do we calculate the left & right shifts swiftly....
int a = # to be shifted
int b = # of times to shift int a
left shift can be calculated as follows:(as per my knowledge..works for both (+/-)ve #'s)
int c = (a)*(2^b)
right shift can be calculated as follows:(as per my knowledge..works only for +ve #'s)
int c = (a)/(2^b)
The above does not work for -ve # - How do we calcluate for large -ve # can anybody help?

HI,
I wanted to know what a concrete class is? What is an ancestor class & how does it differ from a Super class?
What do they mean when they say - Static variables are initialized when the class is loaded the 1st time and instance variables are initialized accordingly in every object created from a class?
short h = 40;(O.K.)
h = h+2;(Why will this give an error?)
byte b = 2;
b +=10;(O.K.)
b= b+10;(Why will this give an error?)


------------------