0% found this document useful (0 votes)
10 views

Day 1 - Java Seminar Notes

The document outlines a 7-day seminar on Java Programming aimed at beginners and intermediate learners, covering core concepts and practical skills in Java. Each day focuses on specific topics, from basic syntax to advanced features like GUI development and database connectivity. Participants will gain foundational knowledge and hands-on experience, preparing them for further learning in software development.

Uploaded by

adityapandji1
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)
10 views

Day 1 - Java Seminar Notes

The document outlines a 7-day seminar on Java Programming aimed at beginners and intermediate learners, covering core concepts and practical skills in Java. Each day focuses on specific topics, from basic syntax to advanced features like GUI development and database connectivity. Participants will gain foundational knowledge and hands-on experience, preparing them for further learning in software development.

Uploaded by

adityapandji1
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
You are on page 1/ 32

Java Programming

K-Scheme

About Seminar -:

This 7-day seminar on Java Programming is designed to introduce students to the


core concepts of one of the most powerful and widely-used programming languages
in the world. Whether you are aiming to build desktop applications, Android apps, or
server-side software, Java provides a robust, object-oriented foundation that is
essential for modern software development.

Throughout this seminar, participants will gain both theoretical knowledge and hands-
on experience, starting from the basics and progressing to advanced features like
object-oriented programming and file handling. Each day is structured to build upon
the previous one, ensuring a clear and logical learning path.

This seminar is ideal for beginners and intermediate learners who are eager to develop
practical programming skills in Java and lay the groundwork for future learning in
software development, mobile app creation, and competitive coding.

Before we begin, it’s important to clarify some common misconceptions. Many


beginners believe that learning Java (or any programming language) will be quick and
easy — something that can be mastered in a few days. In reality, programming is a
skill that takes time, patience, and consistent practice to develop.

This seminar is not a shortcut to becoming a Java expert overnight. Instead, it is a


stepping stone — a strong foundation that will prepare you for deeper learning. You
won’t become a master coder in 7 days, but you will gain the confidence to write Java
programs, understand key concepts, and continue your learning journey independently.

If you come with an open mind, a willingness to practice, and a genuine interest in
learning, this seminar will be a valuable experience for you.
✅ 7-Day Java Seminar Plan ( Based on MSBTE )

Day 1: Introduction to Java & Basic Syntax

Unit I (Part 1):

 Java Features & Programming Environment


 Java Tokens, Data Types, Typecasting, Variables
 Operators and Expression
 Decision Making & Looping Statements
 Class & Object, Access Modifiers (public, private, etc.)

Practical:

 Set up IDE (Eclipse, VS Code)


 Write a simple class and run it
 Use if/else and loops with examples

Day 2: Arrays, Strings, Vectors, and Constructors

Unit I (Part 2):

 Arrays & String classes (String, StringBuffer)


 Vectors & Wrapper Classes
 Constructors (types, overloading), Garbage Collection
 Method Overloading, Nesting, Command Line Arguments

Practical:

 Programs using arrays, strings, and constructors


 Wrapper class conversion tasks
Day 3: Inheritance, Interfaces & Packages

Unit II:

 Types of Inheritance (single, multilevel, hierarchical)


 Method Overriding, final, super keyword
 Abstract Classes & Interfaces
 Packages: Built-in & User-defined

Practical:

Interface and inheritance examples

Create and use a package

Day 4: Exception Handling & Multithreading

Unit III:

 Errors vs Exceptions
 try-catch-finally, throw, throws
 Creating Threads: Thread class & Runnable interface
 Thread Life Cycle, Priority, Synchronization

Practical:

 Exception handling with custom exceptions


 Create multiple threads and demonstrate synchronization

Day 5: GUI with AWT & Swing Components

Unit IV (Part 1):

 AWT: Labels, Buttons, Checkbox, TextField


 Layout Managers: FlowLayout, GridLayout, BorderLayout
 Swing Basics: Difference from AWT, Simple Swing Components

Practical:

 Create GUI with AWT and Swing


 Menu Bar and Layout examples

Day 6: Advanced Swing & Event Handling

Unit IV (Part 2):

 Advanced Swing Components: JTabbedPane, JTable, JTree


 Event Handling: Action, Mouse, Key, Item Events
 Listener Interfaces: ActionListener, MouseListener, etc.

Practical:

 Event-based programs using different listeners


 Interactive forms with advanced UI elements

Day 7: Networking & Database Connectivity

Unit V + VI:

 Socket Programming Basics (TCP/IP, Datagram)


 InetAddress, Socket, URL, URLConnection
 JDBC Basics: Two-tier, Three-tier, Drivers
 Connect to DB using DriverManager, Statement, ResultSet

Practical:

 Client-server communication example


 Insert/Update/Delete operations using JDBC
✅ Theory Topic Checklist (Java Seminar)

Sr. No. Theory Topic Completed

1. Features of Java & Java Environment (JDK, JRE, JVM) ☐

2. Java Tokens, Data Types, and Variables ☐

3. Typecasting, Operators, and Expressions ☐

4. Control Statements (if, switch, loops) ☐

5. Arrays and Vectors ☐

6. String and StringBuffer Classes ☐

7. Wrapper Classes ☐

8. Classes, Objects, and Methods ☐

9. Constructors and Overloading ☐

10. Inheritance and Method Overriding ☐

11. Abstract Classes and Interfaces ☐

12. Packages (Built-in & User-defined) ☐

13. Exception Handling ☐

14. Multithreading and Synchronization ☐

15. GUI with AWT Components ☐

16. GUI with Swing Components ☐

17. Event Handling (Action, Mouse, Key, etc.) ☐

18. Networking (Sockets, InetAddress, URL) ☐

19. JDBC and Database Connectivity ☐


Day 1: Introduction to Java & Basic Syntax

Unit I (Part 1):

 Java Features & Programming Environment


 Java Tokens, Data Types, Typecasting, Variables
 Operators and Expression
 Decision Making & Looping Statements
 Class & Object, Access Modifiers (public, private, etc.)

Practical:

 Set up IDE (Eclipse, VS Code)


 Write a simple class and run it
 Use if/else and loops with examples

Java -:

Java is a high-level, object-oriented programming language that was developed by


Sun Microsystems in 1995. It is one of the most widely used programming languages
today, known for its simplicity, security, and portability.

Key Characteristics of Java:

 Object-Oriented: Java follows the principles of object-oriented


programming (OOP), such as encapsulation, inheritance, polymorphism, and
abstraction. This makes it easier to manage and organize code in large
applications.
 Platform-Independent: The slogan "Write Once, Run Anywhere" reflects
Java's capability to run on any platform that supports the Java Virtual
Machine (JVM). Java code is compiled into bytecode, which can be executed
on any machine that has a JVM, making it platform-independent.
 Simple and Easy to Learn: Java is designed to be easy to use and clean,
reducing the complexity found in other languages. It removes low-level
programming concepts such as pointers, which makes it simpler for beginners.
 Secure: Java includes several security features, such as bytecode verification
and a sandbox model, to prevent unauthorized access and malware from
harming the system.
 Multithreading Support: Java allows the development of multithreaded
applications, enabling efficient CPU usage by performing multiple tasks
simultaneously.
 Rich API: Java provides a comprehensive set of standard libraries and APIs
(like java.util, java.io, java.net) that make it easy to develop applications without
reinventing the wheel.

Java Programming Environment

The Java programming environment refers to the setup and tools needed to write,
compile, and run Java programs on a computer. The Java environment consists of
several key components, each playing an important role in the development and
execution of Java applications.

1. Java Development Kit (JDK)

The JDK is the core software development kit required for Java programming. It
includes everything you need to develop Java applications:

 Java Compiler (javac): Converts Java source code into bytecode that the
Java Virtual Machine (JVM) can execute.
 Java Runtime Environment (JRE): Provides the necessary libraries and
components to run Java programs. It includes the JVM.
 Development Tools: Includes tools like javap (disassembler), javadoc
(documentation generator), and jar (tool to package files)
 To get started with Java, you need to download and install the JDK from the
official Oracle website.
2. Java Runtime Environment (JRE)

The JRE is a part of the JDK but can also be installed separately. It provides the
environment for executing Java programs and includes:

 Java Virtual Machine (JVM): The JVM is responsible for running Java
bytecode. It makes Java platform-independent by translating bytecode into
machine-specific instructions at runtime.
 Java Class Libraries: A large set of pre-built classes that Java programs can
use, such as file I/O, networking, and utilities (e.g., java.util and java.io).

3. Java Virtual Machine (JVM)

The JVM is the engine that enables Java's platform independence. It converts Java
bytecode (the compiled code) into machine code that the operating system can
execute.

Key features of JVM:

 Portability: The JVM allows the same Java program to run on any operating
system (Windows, Linux, macOS, etc.).
 Garbage Collection: The JVM automatically manages memory by cleaning
up objects that are no longer in use.

4. Integrated Development Environment (IDE)

An IDE is a software application that provides tools to write, test, and debug Java
code more efficiently. Some popular IDEs for Java development include:

 IntelliJ IDEA: Known for its powerful features, excellent code suggestions,
and great integration with Java frameworks.
 Eclipse: Open-source and widely used in Java development, particularly for
enterprise-level applications.
 NetBeans: Another open-source IDE with good support for Java
development and excellent for beginners.

Most IDEs offer:


 Code Editor: Where you write your Java code.
 Compiler Integration: Automatically compiles the code as you write it.
 Debugger: Helps you find and fix bugs in your code.
 Graphical User Interface (GUI) Design: Some IDEs offer tools to design
and develop GUIs for Java applications.

Structure of Java Program

Documentation Session

It is used to improve the readability of the program. It consists of comments in Java


which include basic information such as the method’s usage or functionality to make
it easier for the programmer to understand it while reviewing or debugging the code.
A Java comment is not necessarily limited to a confined space, it can appear
anywhere in the code.

The compiler ignores these comments during the time of execution and is solely
meant for improving the readability of the Java program.
There are three types of comments that Java supports

 Single line Comment


 Multi-line Comment
 Documentation Comment

Example

1 // a single line comment is declared like this


2 /* a multi-line comment is declared like this
3 and can have multiple lines as a comment */
4 /** a documentation comment starts with a delimiter and ends with */

Package Statement

 There is a provision in java that allows you to declare your class in a


collection called package.

 There can be only one package statement in a java program and it has to be at
the beginning of the code before any class or interface declaration.

This statement is optional, for example, take a look at the statement below.

package student

This statement declares that all the classes and interfaces defined in this source file are
a part of the student package.

And only one package can be declared in the source file.


Import Statement

Many predefined classes are stored in packages in java, an import statement is used to
refer to the classes stored in other packages.

An important statement is always written after the package statement but it has to be
before any class declaration.

We can import a specific class or classes in an import statement. Take a look at the
example to understand how import statement works in java.

1 import java.util.Date; //imports the date class


2 import java.applet.*; //imports all the classes from the java applet package

Interface Section

1 interface stack
2 {
3 void push(int item);
4 void pop();
5 }

Class Definition

A java program may contain several class definitions, classes are an essential part of
any java program.
This section is used to specify an interface in java.

It is an optional section which is mainly used to implement multiple inheritance in


java.

An interface is a lot similar to a class in java but it contains only constants and
method declarations.

An interface cannot be instantiated but it can be implemented by classes or extended


by other interface.

It defines the information about the user-defined classes in a program.

A class is a collection of variables and methods that operate on the fields.

Every program in java will have at least one class with the main method.

Main Method Class

The main method is from where the execution actually starts and follows the order
specified for the following statements.

Let’s take a look at a sample program to understand how it is structured.

1 public class Ur Engineering Friend


2 {
3 //main method declaration
4 public static void main(String args[])
5 {
6 System.out.println("Welcome to Ur Engineering Friend");
7 }
8 }

Class & Object

In Java (and all object-oriented programming languages), class and object are two
fundamental building blocks.

What is a Class?

 A class is like a blueprint or template.


 It defines what an object will contain (data/variables) and what it can do
(methods/functions).

Real-life Example:

Think of a class as a blueprint for a car. It describes:

 Properties like color, speed, and model.


 Actions like start, stop, and drive.

But the blueprint itself is not a car. It just describes how to build one.

Syntax of a Class:

public class Car {


// properties (variables)
String color;
int speed;
// behavior (method)
void drive() {
System.out.println("The car is driving.");
}}
What is an Object?

An object is a real-world entity created based on a class. It has

State (values of variables)

Behavior (can perform methods

Real-life Example:

If Car is a class, then:

 car1 is a red car with 80 km/h speed.


 car2 is a blue car with 100 km/h speed.

Each car is an object of the class Car.

Creating an Object:

public class Main {


public static void main(String[] args) {
// creating an object of class Car
Car myCar = new Car();
// setting properties
myCar.color = "Red";
myCar.speed = 80;
// accessing method
myCar.drive();
}
}
Java Tokens

1. Keywords

 These are reserved words that have a special meaning in Java


 You cannot use them as variable or method names.

Examples:

class, public, static, void, if, else, while, return, new

Example in code:

public class MyClass {


public static void main(String[] args) {
int age = 20;
}
}

public, class, static, int → keywords

2. Identifiers
 These are names used for variables, methods, classes, etc.
 You create these names yourself.

Rules:

 Must begin with a letter, _ (underscore), or $.


 Cannot be a keyword.
 Case-sensitive (Name and name are different).

Example:

int age;
String studentName;
MyClass obj;

age, studentName, MyClass, obj → identifiers

3. Literals

 These are fixed values used in the code.

Examples:

123 // integer literal3.14 // float/double literal'c' // character literal"Hello" //


string literaltrue // boolean literal

Example:

int x = 100;String name = "Java";boolean isEasy = true;

4. Operators

 These are symbols used to perform operations like addition, comparison, etc.

Types of Operators:

 Arithmetic: +, -, *, /
 Relational: ==, !=, <, >

 Logical: &&, ||, !

 Assignment: =, +=, -=

5. Separators (or Punctuators)

These are used to separate code components.

Examples:

 ; (semicolon) → ends a statement


 {} → define a block
 () → used in methods
 [] → array brackets
 , → separate multiple values

Example:

public static void main(String[] args) {


int[] marks = {90, 85, 70};
}

Type Casting

Type Casting in Java means converting one data type into another.

For example:

Converting an int to float

Converting a double to int

This is useful when you want to store a value of one type into a variable of another
type.
Two Types of Type Casting in Java:

Type Also Called As Description

1. Widening Automatic Casting Smaller → Larger

2. Narrowing Explicit Casting Larger → Smaller

Widening Type Casting (Automatic)

 Java automatically converts smaller data types to larger data types.


 ✅ Safe conversion
No data is lost.

Example:

int a = 10;double b = a; // int to double (automatic)


System.out.println(b); // Output: 10.0

Possible Widening Conversions:

byte → short → int → long → float → double

Narrowing Type Casting (Manual)

 You must manually convert larger data types to smaller data types.

Data may be lost, so use carefully.

Syntax:

targetType variable = (targetType) value;

Example:

double x = 10.75;int y = (int) x; // double to int (manual)


System.out.println(y); // Output: 10

In this case, the decimal part .75 is lost!

Decision Making

In Java, decision-making statements allow your program to choose different paths


based on certain conditions — just like making choices in real life!

Why Use Decision Making?

Imagine this:

"If it rains, take an umbrella. Otherwise, wear sunglasses."

Similarly, in Java:

if (raining) {
takeUmbrella();
} else {
wearSunglasses();
}
Types of Decision-Making Statements in Java:

Statement Description

if Executes block if condition is true

if-else Chooses between two blocks

else-if ladder Checks multiple conditions

nested if An if inside another if

switch Selects from many options (cases)

✅ 1. if Statement

➤ Purpose: Executes code only if a condition is true.

Syntax:

if (condition) {
// Code to execute if condition is true
}

Example:

int age = 20;


if (age >= 18) {
System.out.println("You are eligible to vote.");
}

Output:

You are eligible to vote.

Here, the code inside the if block runs only if the condition (age >= 18) is true.

✅ 2. if-else Statement
➤ Purpose: Runs one block if condition is true, otherwise runs another.

Syntax:

if (condition) {
// Code if condition is true
} else {
// Code if condition is false
}

Example:

int marks = 45;


if (marks >= 50) {
System.out.println("You Passed");
} else {
System.out.println("You Failed");
}

Output:

You Failed

The condition is false, so the else block is executed.

✅ 3. else-if Ladder

➤ Purpose: Check multiple conditions in sequence.

Syntax:

if (condition1) {
// Code if condition1 is true
} else if (condition2) {
// Code if condition2 is true
} else {
// Code if all conditions are false
}

Example:

int marks = 82;


if (marks >= 90) {
System.out.println("Grade A");
} else if (marks >= 75) {
System.out.println("Grade B");
} else if (marks >= 60) {
System.out.println("Grade C");
} else {
System.out.println("Fail");
}

Output:

Grade B

The program checks each condition in order until one is true.

✅ 4. Nested if Statement

➤ Purpose: An if statement inside another if. Useful for multiple levels of


checking.

Syntax:

if (condition1) {
if (condition2) {
// Code if both conditions are true
}
}
Example:
int age = 22;int weight = 58;
if (age >= 18) {
if (weight >= 50) {
System.out.println("You can donate blood.");
}
}

Output:

You can donate blood.

Both conditions must be true for the inner code to run.

✅ 5. switch Statement

➤ Purpose: Useful when you have many fixed choices to select from.

Syntax:

switch (variable) {
case value1:
// Code
break;
case value2:
// Code
break;
...
default:
// Code if no match
}

Example:

int day = 2;
switch(day) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
default:
System.out.println("Invalid day");
}

Output:

Tuesday

switch is better than many if-else statements when checking a single variable against
many values.

Looping In Java

What is Looping?

Looping means repeating a block of code again and again — until a certain
condition is met.
It helps to avoid writing the same code multiple times.

Why Use Loops?

✅ Reduce code length


✅ Automate repetitive tasks
✅ Make the program efficient
Types of Loops in Java:

Loop Type Used When

for loop When you know how many times to repeat

while loop When you want to loop until a condition is true

do-while loop Similar to while, but runs at least once

for Loop

➤ Repeats a block for a fixed number of times

Syntax:

for (initialization; condition; update) {


// code to repeat
}

Example:

for (int i = 1; i <= 5; i++) {


System.out.println("Java");
}

Output:

Java
Java
Java
Java
Java
while Loop

➤ Repeats as long as the condition is true

Syntax:

while (condition) {
// code to repeat
}

Example:

int i = 1;while (i <= 3) {


System.out.println("Hello");
i++;
}

Output:

Hello
Hello
Hello

do-while Loop

➤ Similar to while, but executes the block at least once

Syntax:

do {
// code to repeat
} while (condition);

Example:

int i = 1;do {
System.out.println("Welcome");
i++;
} while (i <= 2);

Output:

Welcome
Welcome

Access Modifiers

What are Access Modifiers?

 Access Modifiers control the visibility (or accessibility) of classes, methods,


and variables from other parts of the program.
 Think of them like permissions or privacy settings:
 Who can see it?
 Who can use it

Java Provides 4 Access Modifiers:

Accessible Within Same Same Subclass (Different


Modifier Anywhere
Class Package Package)

private ✅ Yes ❌ No ❌ No ❌ No

(default)
✅ Yes ✅ Yes ❌ No ❌ No

protected ✅ Yes ✅ Yes ✅ Yes ❌ No

public ✅ Yes ✅ Yes ✅ Yes ✅ Yes

Default (also called package-private): when no modifier is specified.


private Modifier

 Visible only inside the same class


 Used for encapsulation (hiding internal details)

✅ Example:

class Student {
private int rollNo = 101;
void showRoll() {
System.out.println(rollNo);
}
}

rollNo cannot be accessed from outside the Student class.

Default (No Modifier)

 Visible only within the same package


 Used when you want package-level access

✅ Example:

class Car {
String brand = "Honda"; // default access
}
This variable cannot be accessed from another package.

protected Modifier

 Visible within the same package and in subclasses (even in other


packages)

✅ Example:

class Animal {
protected void sound() {
System.out.println("Animal Sound");
}
}

A class that extends Animal in another package can still access sound().

public Modifier

 Visible everywhere in the program


 Most open access level

✅ Example:

public class Hello {


public void greet() {
System.out.println("Hello, Java!");
}
}

✅greet() can be accessed from any class, anywhere.


Programming Checklist Day 1

Easy Level ( MSBTE Oriented )

1. Write a program to check whether a given number is Armstrong or not.


2. Write a program to print all Armstrong number from 0 to 999.
3. Write a program to check whether a given number is prime or not.
4. Write a program to print all prime numbers from 0 to 999.
5. Write a Java program to find out the even numbers from 1 to 100 using for loop.
6. Explain switch case and conditional operator in java with suitable example.
7. Define a class circle having data members Pi and radius. Initialize and display
values of data members also calculate area of circle and display it.
8. Write a program to print fibonacci series up to n.
9. Write a program to print the table of n number.
10. Write a program to show the use of type casting.

Moderate Level ( MSBTE Oriented )

1. Problem: Write a Java program that takes the age of a person as input and prints
whether the person is a Child (age < 12), Teenager (age between 12 and 19), or
Adult (age >= 20).

Concepts:

 If-else statements
 Age validation and classification

2. Problem: Write a Java program that accepts marks as input and prints the
corresponding grade:

Grade A (marks >= 85)

Grade B (marks >= 70 but < 85)


Grade C (marks >= 50 but < 70)

Fail (marks < 50

3. Problem: Write a Java program that calculates the electricity bill using
the following logic:

 Up to 100 units – ₹5 per unit


 101 to 200 units – ₹7 per unit
 Above 200 units – ₹10 per unit

4. Problem: Create a Java program that shows a basic ATM menu with
options

 Withdraw
 Deposit
 Check Balance

Use a loop to keep the ATM running until the user chooses to exit.

5. Problem: Write a Java program to calculate the final bill amount after
applying a discount:

If total > ₹1000 → 20% discount

If total > ₹500 → 10% discount

Else → No discount

Use: if-else ladder


Complex Level -:

1. Problem:
A number is called a Magic Number if the recursive sum of its digits is 1.

Example: 199
1 + 9 + 9 = 19 → 1 + 9 = 10 → 1 + 0 = 1 ✅

Write a program to check if a number is a magic number.


2. Problem:
A number is called a Strong Number if the sum of the factorials of its digits
equals the number itself.

Example: 145 → 1! + 4! + 5! = 145

Write a program to find all strong numbers from 1 to 1000.

Ego Breaker Level -: ( Time -: 7 minutes / program )

1. Secret Pin Lock System

A security pin system allows only numbers that meet all the following
rules:

 Must be a 4-digit number


 The sum of digits must be even
 The number must not contain two same consecutive digits
 The number must not end in 0

Task: Print all such valid pins from 1000 to 9999.

End of Day 1
See You Tomorrow !

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy