Docsity

Class Comparison 1-Java Network Programming-Lab Manual, Exercises of Java Programming

Toggle sidebar
bg1
1. Lets look at JDK
a. You can find your jdk inside the jbuilder7 folder most probably at C:\ drive otherwise
check other drives
b. What is the version of JDK on your system
c. Find out javac and java in jdk/bin folder
2. Writing your first Program
a. Open notepad and type helloworld program
b. Save the file as helloworld.java [be carefull notepad usually saves files as .txt ]
c. Open command prompt by typing cmd in windows start-run utility
d. Change your directory to [ jbuilder7\jdk1.3.1\bin]
e. On command prompt write [javac ] following it write complete path and file name with
extension of your helloworld.java [use slides for help]
f. If there are no errors in your program nothing will be displayed and you will get the
command prompt again
g. Type java and name of your helloworld file (without extension) with complete path
h. Did you get the out put [if not ask for help]
3. Try helloworld program with the following changes
System.out.println(“Hello”+”world”);
System.out.println(“This is a long sentence and cannot be written on a single so have to
write it on at least two line, writing this way seems an error”);
System.out.println(“This line will not \n print on single \line “);
System.out.print(“This text should print”);
System.out.print(“On single “);
System.out.print(“Line Strange..”);
4. Try to write program for the following
a. Convert the age of your friend in months days and print
b. How many leap years have been passed up-to 20004
c. Create arrays of different data types and print them
5. Familiarize yourself with the use of various operators
6. Add these lines just before the main method
/** The main method
* The starting point of execution contains all the logic and code for the execution * of a
program */
Now once again go to jdk/bin and write the following on command prompt
javadoc path\helloworld.java
Now open the directory where you have saved the java file and find index.html open it and
view it
Java Programming Day-01
Lab-session-01
Docsity.com

Partial preview of the text

Download Class Comparison 1-Java Network Programming-Lab Manual and more Exercises Java Programming in PDF only on Docsity!

1. Lets look at JDK a. You can find your jdk inside the jbuilder7 folder most probably at C:\ drive otherwise check other drives b. What is the version of JDK on your system c. Find out javac and java in jdk/bin folder 2. Writing your first Program a. Open notepad and type helloworld program b. Save the file as helloworld.java [be carefull notepad usually saves files as .txt ] c. Open command prompt by typing cmd in windows start-run utility d. Change your directory to [ jbuilder7\jdk1.3.1\bin] e. On command prompt write [javac ] following it write complete path and file name with extension of your helloworld.java [use slides for help] f. If there are no errors in your program nothing will be displayed and you will get the command prompt again g. Type java and name of your helloworld file (without extension) with complete path h. Did you get the out put [if not ask for help] 3. Try helloworld program with the following changes System.out.println(“Hello”+”world”); System.out.println(“This is a long sentence and cannot be written on a single so have to write it on at least two line, writing this way seems an error”); System.out.println(“This line will not \n print on single \line “); System.out.print(“This text should print”); System.out.print(“On single “); System.out.print(“Line Strange..”); 4. Try to write program for the following a. Convert the age of your friend in months days and print b. How many leap years have been passed up-to 20004 c. Create arrays of different data types and print them **5. Familiarize yourself with the use of various operators

  1. Add these lines just before the main method** /** The main method
    • The starting point of execution contains all the logic and code for the execution * of a program */ Now once again go to jdk/bin and write the following on command prompt javadoc path\helloworld.java Now open the directory where you have saved the java file and find index.html open it and view it

Java Programming Day- 01

Lab-session- 01

Docsity.com