why java is platform independent?
Answers were Sorted based on User's Feedback
Answer / gunjan
java is platform independent as JVM compiles source code to
its byte code which is then interpreted to object code.thus
any machine having a java compiler can execute that byte
code.this does not depends on the hardware or the OS of the
system
Is This Answer Correct ? | 42 Yes | 9 No |
Answer / guest
Java is compiled to an intermediate form called byte-code.
A Java program never really executes natively on the host
machine. Rather a special native program called the Java
interpreter reads the byte code and executes the
corresponding native machine instructions. Thus to port
Java programs to a new platform all that is needed is to
port the interpreter and some of the library routines. Even
the compiler is written in Java. The byte codes are
precisely defined, and remain the same on all platforms.
Is This Answer Correct ? | 36 Yes | 8 No |
Answer / pawan mangal
java uses two process compiler and second one interpreter
compiler converted source code in to byte code and this byte code is universalize because it can be run by any jvm(java virtual machine).which is a interpreter
suppose u create a java programe in windows and u compile it then u have their byte code*(.class file)as discussion it can be run on any jvm means(linx )
Is This Answer Correct ? | 9 Yes | 1 No |
Answer / coder
JVM does not compile Java source code to byte code. It is
the Java Compiler which does that. JVM runs on the target
machine which interprets the byte code and runs the program
on the target machine.
Java is not platform independent. Though you write the Java
source code, somebody else ( Sun Microsystems ) have done
the hardwork to implement JVM for the platform which is
going to run your program. "Java is Platform Independent"
is an illusion.
Is This Answer Correct ? | 10 Yes | 4 No |
Answer / jagan_kumar
java compiler makes the class file which is not dependent
on the hardware or software of the system where we compiled.
Every system has its own JVM(System dependent) and will
takes .class file and produces the code which is executable
on that particular system itself.
So JVM makes the code portability.
hence JVM makes the JAVA as Platform Independent.
JAVA-JVM=NO USE of producing System indipendent code.
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / madhan
yes java is a platform independent. JVM(java virtual
machine) is used in java , that jvm can be converted source
code into byte code so java known as platform independent.
Is This Answer Correct ? | 12 Yes | 9 No |
Answer / raj kumar.d
When compile a java code, the source code is converted into a byte code with the help of java interpreter. So java called platform independent.
Is This Answer Correct ? | 2 Yes | 0 No |
Java is called platform independent because of its byte codes which can run on any system irrespective of its underlying operating system.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / asad raza
Bismillahir Rahmanir Rahim..
yes java is plateform independent, because its compiler
first convert the java code into byte-code(machine
language), which is the code that every plateform
understand, that's why it is called " plateform independent"
Is This Answer Correct ? | 3 Yes | 5 No |
Answer / badrinath
java is platform independent b coz ,java have java virtual
machine which make java plateform
independent..jvm convert input source code into bye code
which is run on any plateform..
Is This Answer Correct ? | 0 Yes | 2 No |
main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. “Hello world” c. Compile error d. “hello world”
int a=1; printf("%d %d %d",a++,a++,a); need o/p in 'c' and what explanation too
Is the following code legal? struct a { int x; struct a b; }
main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }
main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3); }
Which one is taking more time and why ? :/home/amaresh/Testing# cat time.c //#include <stdio.h> #define EOF -1 int main() { register int c; while ((c = getchar()) != EOF) { putchar(c); } return 0; } ------------------- WIth stdio.h:- :/home/amaresh/Testing# time ./time_header hi hi hru? hru? real 0 m4.202s user 0 m0.000s sys 0 m0.004s ------------------ Witout stdio.h and with #define EOF -1 =================== /home/amaresh/Testing# time ./time_EOF hi hi hru? hru? real 0 m4.805s user 0 m0.004s sys 0 m0.004s -- From above two case , why 2nd case is taking more time ?
Write a program to receive an integer and find its octal equivalent?
main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }
There is a lucky draw held every day. if there is a winning number eg 1876,then all possible numbers like 1867,1687,1768 etc are the numbers that match irrespective of the position of the digit. Thus all these numbers qualify fr the lucky draw prize Assume there is no zero digit in any numbers. write a program to show all the possible winning numbers if a "winning number"is passed as an arguments to the function.
What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }
You are given any character string. Find the number of sets of vowels that come in the order of aeiou in the given string. For eg., let the given string be DIPLOMATIC. The answer returned must be "The number of sets is 2" and "The sets are "IO and AI". Vowels that form a singleton set must be neglected. Try to post the program executable in gcc or g++ or in java.
write a program to count the number the same (letter/character foreg: 's') in a given sentence.