AddThis

Tuesday 8 January 2019

Java basic questions / Java basic concepts / Java basics

Q1. What is source code?
Ans. Human understandable code written using high level programming is called source code.

Q2. What is native code or binary code or machine code?
Ans. Machine understandable code written using low level programming language is called as native code.

Q3. What is byte code?
Ans. JVM understandable code generated by Java compiler is called as byte code. Byte code is also called as magic code.

Q4. Why C and C++ are platform dependent?
Ans. When we compile C or C++ program on one operating system then compiler generates that operating system understandable native code. This native code generated on one OS will not run on other OS directly.

Q5. Why Java is platform independent?
Ans. When we compile Java code on one operating system the Java compiler generates byte code. We can run that byte code on any OS which has the JVM.
JVM understands the byte code and generate native code for the corresponding OS. 
Because of byte code and JVM, Java is platform independent.
Because of platform independent, we can use write once run anywhere (WORA).

Q6. Which program is faster written in Java or in C, C++?
Ans. C or C++ program execution is faster than Java program because compiled code of C or C++ program contains binary code and that binary code will be executed directly whereas compiled code of Java program contains byte code and that byte code will be converted to native code first and then native code will be executed.

Q7. What is Java compiler?
Ans. Java compiler is a program developed in C or C++ programming language with the name "javac".
It is responsible for the following tasks:
  • It checks syntactical or grammatical errors of the programs.
  • It converts source code to bye code.
Q8. What is Java interpreter?
Ans. Java interpreter is a program developed in C or C++ programming language with name "java".
It is responsible for the following tasks:
  • It converts byte code to native code line by line.
  • It executed that native code.
Note: Because of converting and executing line by line, Java program execution was slower in initial versions of Java.

Q9. What is JIT compiler?
Ans. JIT (Just-In-Time) compiler is a component of the Java Runtime Environment. JIT compiler compiles or translates or converts the necessary part of the byte code into machine code instead of converting line by line. Because of this, performance of Java program has improved.

Q10. What JDK (Java Development Kit) / SDK (Software Development Kit)?
Ans. It is a set of various utility programs which are required for developing and executing the Java programs.
It is platform dependent. Various JDKs are provided for various operating systems.
Following are various utility programs provided under JDK:
  1. Java Development Tools
    1. javac
    2. java
    3. javap
    4. jar
    5. etc
  2. Source files
  3. JRE
  4. etc
Q11. What is JRE?
Ans. JRE stands for Java Runtime Environment. It is implementation of JVM. It contains class libraries, interpreter, JIT compiler etc. Only JRE is enough to run the Java program.

Q12. What is JVM?
Ans. JVM stands for Java Virtual Machine. It is specification provided by SUN Microsystem whose implementation provides an environment to run our Java applications.
SUN's implementation of the Java Virtual Machine (JVM) is itself called as JRE. SUN's JRE is available as a part of JDK and also as a separate application.
Many vendors have implemented JVM. Some of then are SUN JRE, IBM JRE, Oracle JRE etc.





No comments:

Post a Comment

100 AWS Services in Just One Line Each

  100 AWS Services in Just One Line Each Amazon EC2:  Virtual servers in the cloud. Amazon S3:  Scalable object storage service. Amazon RDS:...