Section I: Understanding Java Fundamentals (15 – 20%):

 

 

#

Topics

 

1

 

Scanner Class methods : next(), nextInt(), nextDouble() and nextLine()

 

·         Example Program  (Study the output)  

 

2

 

Local variables Vs global (static) variables:

 

·         Example Program (Study the program output)

 

3

 

Java command line arguments

 

·        Example Program

 

 

·         Compile command:

o   javac  Program.java

 

·         Run command (and input values to the args[] array in the main method):

o   java   Program  John 100 0.2  

 

·         The run command inserts the input String values into the args[] array as below:

 

args[0] = “John”;

 

args[1] = “100”;

 

args[2] = “0.2”;

 

 

4

 

Why is the main method public, static and void in Java?  (Refer to the first answer)

 

Can you remove the static keyword in main()?

 

·       No. The program will compile successfully but will not execute.