3/1/25 -------- Q)JDK Vs JRE Vs JVM DIAGRAM Q)How are Java platforms classified? 1)Java SE (Standard Edition Of Java)+stand-alone applications 2)Java EE(Java Enterprise Edition )=>web applications 3)Java ME(Java Micro Edition)=>Mobile applications Q)On which cycle does a Computer Application run? =>IPO(Input Process Output) Q)How to read data from the keyboard in a Java program? =>by using the library methods of Scanner class. Q)Java program to perform the addition of two numbers interactively. //InteractiveAddition.java import java.util.Scanner; class InteractiveAddition{ public static void main(String args[]){ Scanner scanner=new Scanner(System.in); System.out.print("Enter the first number:"); int n1=scanner.nextInt(); System.out.print("Enter the second number:"); int n2=scanner.nextInt(); int sum=n1+n2; System.out.println("The sum is "+sum); }//main }//class =>In the above program we have used 4 Java classes. =>InteractiveAddition is the user defined class(our own created class). =>Scanner,String and System are library classes(pre-defined classes) =>Scanner class belongs to java.util package. =>System & String belong to java.lang package. For every Java program, java.lang package is automcatically(implicitly) available.Therefore we need not import String & System classes. Q)What are the similarities between print() and println()? =>Both are library methods. =>Both are used to display data on the monitor in Java program. Q)What is the difference between print() and println()? =>println() method prints a blank line after printing the data. Where as print doesn't. Q)What is a local variable? =>A variable declared inside a vmethod is known as a local variable. Q)What is the output of the following Java application? class Output{ public static void main(String args[]){ int a; System.out.println(a); } } Ans:- The above program causes compilation error. Reason:- Using a local variable without initializing it is syntactical error in Java. Q)What is a comment in a Java application? =>Textual description of the Java application written within the source code which is ignored by the compiler is nothing but a comment. =>We have 2 types of implementation comments. 1)single line comment 2)multi-line comment =>Single line comment starts with "//" and ends with the physical line =>Multi-line comment starts with "/*" and ends with "*/". For eg. /* This application is developed on 3-01-25 by AshokIt team. */ class Output{ public static void main(String args[]){ int a;//local variable int sum=a+10;//using a local variable } } Q)What is a data type? =>data type is a one that specifies the kind of data that can be stored in computer's memory Q)How are data types classified in Java? 1)primitive/pre-defined/system-defined/fundamental/basic data types 2)user defined data types Q)What are the primitive data types in Java? =>There are 8 primitive data types in Java. 1)byte 2)short 3)int 4)long 5)float 6)double 7)char 8)boolean