ShivKumar Rajawat

Greenhorn
+ Follow
since Mar 13, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by ShivKumar Rajawat

Thanks Jesper,
you are right. i have Oracle Jinitiater in my system that is causing this problem.

thanks a lot guys ..
18 years ago
Thanks Paul and Urs,
I checked the version of java. this is "1.3.1.9"

D:\>java -version
java version "1.3.1.9"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1.9)
Java HotSpot(TM) Client VM (build 1.3.1-rc2-b22, mixed mode)

then recomplied the class with
D:\>javac -source 1.3 shiv/hi.java

even then the same error persists.

who told me to be a software engineer!!
18 years ago
Hi everybody
I am trying to run a small program on a new "Windows XP" system. i am using jdk 1.5.0. it's the same old "hello world" program. it compiles without any errors or warnings , but when i try to run this program it displays this exception :

Exception in thread "main" java.lang.UnsupportedClassVersionError: hi (Unsupport
ed major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)


the class code is :

public class hi
{
public static void main (String [] args)
{
System.out.println("hi");
}
}


can somebody please explain what may be causing this exception
18 years ago
Hi Live,
After this replacement your inner class structure becomes :

class MethodLocalClass {
System.out.println(a);
}
instead of puuting this statement directly inside the class , could you please try creating a member method and then put this statem,ent in that method.
Hi karnatam ,
regarding files there wont be any tough questions as such. But still you need to know class Hierarchy of all the classes relatedd to IO. function which you can invoke on an instance of file. what are the constructer arguments for the calsses related to IO. etc etc
Regarding object streams: do not go much inside, whatever you know should be enough.
hi all,
suppose the bean we were trying to find is not abilable or it was not set in any scope. in that case container creates a new instance of bean and sets it into the appropriate scope.

the statement that is used (after translation of JSP to servlet) to create an instance will be like
A identifier = new B()

here A is the class/interface which you defined under "type" attribute . B is the class which you defined under "class" attribute . if you do not define a type attribute , class attribute will be used for type also.
Hi,
this is the code that produces the output:

((Dog)a[x]).doStuff(); //Output : "a:"
a[x].doStuff(); //Output : "a:"
System.out.println("if instance of dog");

This is because array a has been defined as an array of animals.
for the 2nd statement

a[x].doStuff();

doStuff is a static method so at compile time this statement will be translated to:

Animal.doStuff();

so the statement 2 generates the out put "a:" , I am not sure how exactly complier behaves for first line . but i think it has something to do with the same concept.
Hi Bhavesh,
many of the links can be found on javaranch itself. anyways i had few mock exams in my inbox. i shall mail you that .. please give me you id i'll forward you those.
Iteration over an arraylist is faster then linked list.
I do not really know the reson, but i think arraylists use Arrays in background.. that may be why ther are faster.
HI,
I did not see any such questions in SCJP 5.0 exam. I took exam last year July 2006.
Hmmmmm ....
Archna,
Assert statements are not guaranteed to execute. ( mostly they are enabled while testing). But after the code is deployed they will probably be disabled . So we should not try such things in assert statements.

In this case you are saying x-- in a assert statement. and you can not ensure whether this will be executed !!

We should not a write a program whose output depends on whether assertions were enabled or not.
I do not really understand what is meant by postconditions. But yes Archna you are right about arguments to public methods.

In the second example the argument is "String code" . and we are not asserting on "code" that is why this rule can not be applied in the 2nd example.
Right Srinivasan.
Archna you can follow this simple process to find out the magnitude:

If leftmost digit is 0 : That means the number is positive, and the bit pattern represents the magnitute.

Now second case : if left most bit is 1 :
that means the number is nagative. so do like this;
suppose the number is : 1111 1010

Step:1 Convert the zeros into ones , and ones in to zeros
so now the bit pattern is : 00000 0101

Step 2: Add 1 to the bit pattern obtained in step 1
no bit pattern becomes : 0000 0110

now the bit pattern obtained in step 2 represent the magnitude of the number
in this example the number would be: -6