Java Questions with Answers #1

Explain the various features of the java programming language.

Various features of java programming language are as given below:

1.  Java is very simple programming language.Even though you have no programming background you can learn this language comfortably.
2.  Java is popular beco’z it is an object oriented programming language like C++.
3.  Platform independence is the most exciting feature of java. That means programs in java can be executed on variety of systems.This feature is based on the goal “write once, run anywhere and at anytime, forever”.
4.  Java supports multithreaded programming which allows a programmer to write such a program that can be perform many tasks simultaneously.
5.  Thus robustness is the essential criteria for the java programs.
6.  Java is designed for distributed systems. Hence two different objects on different computer can communicate with each other.  This can be achieved by RMI (Remote Method Invocation)

Why java is known as Platform-independent language?

Java is called Platform independent because the programs in java can be executed on variety of systems.This feature is based on the goal “write once, run anywhere and at anytime, forever”.

What do you mean by BYTECODE? What is JVM and JIT?

Bytecode is an intermediate form of java programs. Bytecode consists of optimized set of instructions that are not specific to processor. We get bytecode after compiling the java program using a compiler called javac. The bytecode is to be executed by java runtime environment which is called as Java Virtual Machine (JVM). The programs that are running on JVM must be compiled into a binary format which is denoted by .class files. The JVM executes .class or .jar files, by either interpreting it or using a just-in-time compiler (JIT). The JIT is used for compiling and not for interpreting the file. It is used in most JVMs today to achieve greater speed. The bytecode verifier verifies all the bytecode before it is executed.

Explain the general java program execution.

General java program execution

Describe the typical java program structure.

Any java program can be written using simple text editor like notepad or WordPad. The file name should be same as the name of the class used in the corresponding java program. The extension of the file name should be .java.
This is my First Java Program
class FirstProgram
public static void main(String args[])
System.out.println(“This is first program”);


In our First Java program, on the first line we have written a comment statement.This is a multi-line comment.
Then actual program starts with 

class FirstProgram
Here class is keyword and FirstProgram is a variable name of the class. The class definition should be within the curly brackets. Then comes

public static void main(String args[])
This line is for function void main().The main is of type public static void.  Public is a access mode of the main() by which the class visibility can be defined.  Typically main must be declared as public.

The parameter which is passed to main is String args[]. Hence String is a class name and args[] is an array which receives the command line arguments when the program runs,

System.out.println(“This is first program”);

To print any message on the console println is a method in which the string “This is first program” is written. After println method, the newline is invoked. 

Java program is a case sensitive programming language like C or C++.

See also

Do you have a Java Problem?
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of or the content authors.