Java programming manual, Study notes of Java Programming

Java How To Program

Typology: Study notes

2014/2015

Uploaded on 09/15/2015

MaxitoAheer
MaxitoAheer 🇵🇰

1 document

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Programming Practical Manual
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Java programming manual and more Study notes Java Programming in PDF only on Docsity!

Table of Contents

Author Hassan Shahzad Aheer

Faculty Computer Science

Email [email protected]

Personal Details

Student Name Hassan Shahzad Aheer Roll # 15SBSCS

Department : Computer science

Section 2 A

Assignment Detail : Assignment Title : Java Programming Manuals Project Type : - Subject Name or Code : CS 10 2 Object Oriented Programming Coordinator or Tutor : Abdul Hafeez Khan Manual # 01 Due Date : Submission Date : Signature :

Experiment # 1

Objective:

To implement the basic concepts of Net Beans.

AIM:

Students will be able to understand the basic concept of Net Beans usage.

Required Tools /Equipment’s

 Windows OS

 JDK

 Net Beans IDE

Theory

1.1 Setting Up the Project

To create an IDE project:

  1. Start NetBeans IDE.
  2. In the IDE, choose File > New Project, as shown in the figure below.
  1. In the New Project wizard, expand the Java category and select Java Application as shown in the figure below. Then click Next.

In the Name and Location page of the wizard, do the following

(as shown in the figure below):

 In the Project Name field, type HelloWorldApp.  Leave the Use Dedicated Folder for Storing Libraries checkbox unselected.

 In the Create Main Class field, type helloworldapp.HelloWorldApp.

1.2 Adding Code To Your Generated Source File

Because you have left the Create Main Class checkbox selected in the New Project

wizard, the IDE has created a skeleton main class for you. You can add the "Hello

World!" message to the skeleton code by replacing the line:

Save the change by choosing File > Save.

The file should look something like the following code sample.

package helloworldapp; /**

  • @author Maxito */ public class HelloWorldApp {

/**

  • @param args the command line arguments */ public static void main(String[] args) { System.out.println("Experiment # 1"); }

}

1.3 Compile And Running The Program

Because of the IDE's Compile on Save feature, you do not have to manually compile

your project in order to run it in the IDE. When you save a Java source file, the IDE

automatically compiles it.

The Compile on Save feature can be turned off in the Project Properties window.

Right-click your project, select Properties. In the Properties window, choose the

Compiling tab. The Compile on Save checkbox is right at the top. Note that in the

Project Properties window you can configure numerous settings for your project:

project libraries, packaging, building, running, etc.

To run the program.

 Press Shift + F6 to run your program or click on run button

The next figure shows what you should now see.

Congratulations! Your program works! If there are compilation errors, they are marked with red glyphs in the left and right margins of the Source Editor. The glyphs in the left margin indicate errors for the corresponding lines. The glyphs in the right margin show all of the areas of the file that have errors, including errors in lines that are not visible. You can mouse over an error mark to get a description of the error. You can click a glyph in the right margin to jump to the line with the error.

Student’s task:

Answer the following questions

Q1; Write a program in java to declare, initialize and print each data types?

*/

  • Experiment # 1 Question # 1
  • Hassan Shahzad Aheer
  • [email protected] / package dataTypes; public class DataTypes { public static void main(String[] args) { // primitive data types*

boolean bool = false; char ch = 'a'; byte by = 26; int in = 86; float fl = 89.6F; double dou = 77.8; String name = "SMIU University";

// display the out put of the datatypes System.out.println("Boolen : " +bool); System.out.println("Char : "+ch); System.out.println("byte : "+by); System.out.println("Integer : "+in); System.out.println("Float : "+fl); System.out.println("Double : "+dou); System.out.println("String : "+name);

} }

Output

Q 2 ; Write a program in java to use two variables of integer, float and double and

perform following arithmetic operations (+, - , *, /)?

*/

  • Experiment # 1 Question # 2
  • Hassan Shahzad Aheer
  • [email protected] / package arithmeticOperations; public class Operations { public static void main(String[] args) {*

// define variable for store the user input int a, b;

// to create object of scanner class // which help us to take input form user Scanner input = new Scanner(System.in);

// prompt to user for input System.out.print("Enter 1st Number : ");

// get input form user and store in variable called a a = input.nextInt();