Before learning Java, one must be familiar with these common terms of Java introduction to java programming.

1.  Java Virtual Machine(JVM):  This is generally referred to as JVM. There are three execution phases of a program. They are written, compile & run the program.

  • Writing a program is done by a java programmer like you & me.

  • The compilation is done by the JAVAC compiler which is a primary Java compiler included in the Java development kit (JDK). It takes the Java program as input & generates bytecode as output.

  • In the Running phase of a program, JVM executes the bytecode generated by the compiler.

Now, we understand that the function of Java Virtual Machine is to execute the bytecode produced by the compiler. Every Operating System has a different JVM but the output they produce after the execution of bytecode is the same across all the operating systems. This is why Java is known as a platform-independent language.

2. Bytecode in the Development process:  As discussed, the Javac compiler of JDK compiles the java source code into bytecode so that it can be executed by JVM. It is saved as a .class file by the compiler. To view the bytecode, a disassembler like javap can be used.

3. Java Development Kit(JDK): While we were using the term JDK when we learned about bytecode & JVM. So, as the name suggests, it is a complete Java development kit that includes everything including compiler, Java Runtime Environment (JRE), java debuggers, java docs, etc. For the program to execute in java, we need to install JDK on our computer in order to create, compile & run the java program.

4. Java Runtime Environment (JRE): JDK includes JRE. JRE installation on our computers allows the java program to run, however, we cannot compile it. JRE includes a browser, JVM, applet support, & plugins. For running the java program, a computer needs JRE.

5. Garbage Collector: In Java, programmers can’t delete the objects. To delete or recollect that memory JVM has a program called Garbage Collector. Garbage Collectors can recollect the objects that are not referenced. So Java makes the life of a programmer easy by handling memory management. However, programmers should be careful about their code whether they are using objects that have been used for a long time. Because Garbage cannot recover the memory of objects being referenced.

6. ClassPath: The classpath is the file path where the java runtime & Java compiler look for .class files to load. By default, JDK provides many libraries. If you want to include external libraries they should be added to the classpath. 


System.out.println() 

In Java, System.out.println() is a statement which prints the argument passed to it. The println() method displays results on the monitor. Usually, a method is invoked by objectname.methodname(). 

Syntax : class.obj.method() 

 

Java nextLine() method 

The nextLine() method of Scanner class is used to take a string from the user. It is defined in java.util.Scanner class. The nextLine() method reads the text until the end of the line. After reading the line, it throws the cursor to the next line. 

syntaxpublic String nextLine()   

 


Scanner

Scanner is a class in java.util package used for obtaining the input of the primitive types like int, double, etc. & strings.

syntax: Scanner sc=new Scanner (System.in);


1.  Comments: Comments are used for explaining code & are used in a similar manner in Java or C or C++. Compilers ignore the comment entries & do not execute them. Comments can be of a single line or multiple lines.

Single line Comments:

Syntax:

// Single line comment

Multi-line comments:

Syntax:

/* Multi line comments*/

2.  import java.io.*: This means all the classes of the io package can be imported. The Java io package provides a set of input & output streams for reading & writing data to files or other input or output sources.

3.  class: The class contains the data & methods to be used in the program. Methods define the behaviour of the class. Class GFG has only one method Main in JAVA.

4.  static void Main(): static keyword tells us that this method is accessible without instantiating the class. 

5.  void: keywords tell that this method will not return anything. The main() method is the entry point of our application.

6.  System.in: This is the standard input stream that is used to read characters from the keyboard or any other standard input device.

7.  System.out: This is the standard output stream that is used to produce the result of a program on an output device like the computer screen.

8.  println(): This method in Java is also used to display text on the console. It prints the text on the console & the cursor moves to the start of the next line at the console. The next printing takes place from the next line.

9.  String []args: This is the argument passed to the main function which is an array of strings with the array name args. One can choose their own flexible name but this name is used by many developers.


some basic java Questions

1) Write a simple Java program to display "Hello World" & compile this java

program & execute.

2) Write a Java program to display your personal information such as name, city,

state, email etc.

3) Write a Java program to print 'Hello' on screen & then print your name on a

separate line.

4) Write a Java program to display the following pattern.


also read


demonstrate Multiple Inheritance.


 java program to demonstrate Multilevel Inheritance.