0% found this document useful (0 votes)
6 views6 pages

LAB 1 (Java)

This document outlines Lab 1 for Software Engineering students, focusing on the introduction to the NetBeans IDE and basic Java programming. It includes objectives, theoretical descriptions of Java and NetBeans, and detailed lab activities such as setting up NetBeans, writing a simple Java program, understanding program structure, and experimenting with output. Additionally, it emphasizes the importance of comments and documentation in coding, along with specific lab tasks for practice.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

LAB 1 (Java)

This document outlines Lab 1 for Software Engineering students, focusing on the introduction to the NetBeans IDE and basic Java programming. It includes objectives, theoretical descriptions of Java and NetBeans, and detailed lab activities such as setting up NetBeans, writing a simple Java program, understanding program structure, and experimenting with output. Additionally, it emphasizes the importance of comments and documentation in coding, along with specific lab tasks for practice.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Department of Software Engineering

LAB 1: Introduction to NetBeans, Writing Java


programs, Basic Programming Structure of Java

Objectives
In this lab, you will become familiar with the Netbeans Integrated Development
Environment (IDE), write your first Java program, and understand the basic structure
of a Java program.

Theoretical
Description
Java Programming
Language:
Java programming language is an interpreted programming language, that is, when
the source code is compiled into binary file, it needs an interpreter called Java
Virtual Machine (JVM) to run it. Java compiler is called [Link], and interpreter is
called [Link].
The Figure below shows a complete path of running Java programs.

NetBeans: NetBeans is an integrated development environment used in


computer programming. A popular IDE simplifies Java development by providing a
user-friendly environment.

Lab Activities:
Department of Software Engineering

Task 1: Setting Up NetBeans


• Launch NetBeans IDE on your computer.
• Configure your workspace and create a new Java project.
• Familiarize yourself with the NetBeans interface, including the Package
Explorer, Editor, and Console.

Click on the new project

1. Starting with NetBeans:

To write code and make class you have to create a new project in NetBeans. You
will see this window. Select Java Application
Department of Software Engineering

Click Next
Configuration start

After configuration completes give the name of the project of your choice
Department of Software Engineering

Click Finish successfully project created and a sample code shown in the screen

Now start writing your code as you use to write in notepad.

Task 2: Writing Your First Java Program


• Create a new Java class called "HelloWorld."
Department of Software Engineering

• Write a simple Java program that displays "Hello, World!" on the console.
• Save the file and run the program to verify its output.
Program1:
public class HelloWorld {
public static void main(String[] args) {
// TODO Auto-generated method stub
[Link](" Hello, World ! ");//println() displays the string which
is passed to it.
}

Task 3: Understanding the Basic Structure


1. Class Declaration → public class HelloWorld { ... }

2. Main Method → public static void main(String[] args)

3. Statements → Code inside { }, such as [Link]("Hello, World!");

Task 4: Experimenting with Output


• Modify the Java program to display a different message of your choice.
• Run the program again to observe the updated output.

public class HelloWorld {


public static void main(String[] args) {
[Link]("Welcome to Java
Programming!");
}
}

Task 5: Comments and Documentation


• Add comments to your Java program to explain its functionality.
• Understand the importance of code documentation for program clarity and
maintenance.

Let us look at a simple code that will print the words Hello World.
Department of Software Engineering

public class MyFirstJavaProgram {

/* This is my first java program.


* This will print 'Hello World' as the output
* These are multiline coments
*/

public static void main(String []args) {


[Link]("Hello World"); // prints Hello World
}
}

Variable Declarations:

class Program2 { public static void main(String args[]) {


int a,b,c; //this statement declares three variables a, b and c.
a=2;
b=3;
c=a+b;
[Link]("Sum of two numbers = "+c); } }

Naming Conventions:
PascalCase for class names: first letter of each word is capital
camelCase for functions: first letter small others initials are capital

LAB TASKS:
1. Write a java program to print your name and roll number.
2. Write a program to declare three variables; a, b, and c. Assign some values to
a b and can print values.

3. Write a Java program to add two numbers.

You might also like