Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Java summary for beginners

Rating
-
Sold
-
Pages
19
Uploaded on
02-06-2021
Written in
2020/2021

This is a summary document to facilitate students to understand java programming language without signing up for a lot of pages. It contain exercises and examples for each sub-course.

Institution
Course

Content preview

Java Programming
--------------------------
02/06/2021
--------------
1. Introduction
2. Setting Java working environment
3. First Java Program
4. Variables and Methods in Java
5. Getting Data from keyboard
6. Arrays and ArrayList
7. Control Statements
------------------------------
1. Introduction to Java Programming
----------------------------------------------
-> Java is a high level programming language
-> Java is pure object oriented programming language
-> Java was created by Sun Microsystem in 1995
-> Java is good in developing small and large scale applications
-> Java uses Application Programming Interface(API) to simplify the work of
programmers
-> Java support multithreading
-> Java organizes related classes in a package
-> Java has three big components:
=>Java2SE: Java 2 Standard Edition used to develop small application
=>Java2EE: Java 2 Enterprise Edition used to deevelop large scale
applications
=>Java2ME: Java 2 Micro-Edition used to develop Applications for mobile and
hand held devices
-> Java is excellent in developing Graphical User Interface(GUI) using Java Swing
-> Java is excellent in manipulating database using Java Database
Connectivity(JDBC) API
-> Java is excellent in developing web applications using Java Servlet and Java
Server Page(JSP)
-> Java simplifies Software development process by using Frameworks, java has many
Frameworks but the most popular is Spring
-> Java Frameworks use Model View Controller (MVC) components which separates
presentation from business logic of software.
-> Java is excellent in developing secured applications and data protection
-> Java Server Faces(JSF) is a framework which is used to develop faster and
dynamic web applications=> JSF is part of this course
---------------------------------------------
2. Setting Java working environment
-----------------------------------------------
-> To run Java programs we first install:
=> Java Development Kit(JDK for this course JDK 1.8 is used)
=> Integrated Development Environment(IDE, for this course JCreator and Netbeans
are used but Eclipse also is good)
-> We need to configure environment variables:
=> CLASSPATH=C:\Program Files\Java\jdk1.8.0_162\bin
=> PATH=.;C:\Program Files\Java\jdk1.8.0_162\bin
-> JDK has compiler and Interpreter (JVM)
-> JVM means is Java Virtual Machine, a Java component which interpretes compiled
java classes (Bytecode)
-----------------------------------------------
3. First Java Program
------------------------------------
class FirstProgram
{
public static void main(String args[])

,{
System.out.println("Hello CS2 Musanze Students");
}
}
------------------------------------
4. Variables and Methods in Java
----------------------------
There 2 types of variables: Local Variable and Global Variable
-> Local Variable: is declared inside a method
-> Global Variable: is declared before any method, it is available in the whole
program
=> Variables are declared using data types, their names start with letter or
underscore and do not contain free space
---------------------
Example:
----------
class MyVariables
{
static int c;//global is c
public static void main(String args[])
{
int a=10;//a and b are local variable
int b=20;
c=a+b;
System.out.println("Sum="+c);
}
}
-----------------------------
Methods in Java:
----------------------
There are 2 types of Methods: Method with Arguments and Method without Arguments.
-> Method without Arguments:
---------------------------
Format:
---------
DataType MethodName()
{
Statements;
}
-----------------
Method with Arguments
--------------------------
Format:
-------
DataType MethodName(DataType Arg1, DataType Arg2,..., DataType ArgN)
{
Statements;
}
---------------------
Example:
------------
class MyMethods
{
static String name;
static float c;
public static float product(float a,float b)
{
c=a*b;
return c;

, }
public static void Display()
{
System.out.println("Product="+c);
name="Silas";
}
public static void main(String args[])
{
product(12.5,6.4);
System.out.println("Hello "+name);
Display();
}
}
-----------------------------
5. Getting Data from keyboard
-------------------------------------
There 4 ways of getting input from user:
-> Using Scanner class
-> Using DataInputStream class
-> Using BufferedReader class
-> Using JOptionPane class
------------------------
5.1 Getting Data using Scanner class
------------------------------------------
-> Scanner class is found in java.util package
-> Scanner class has useful methods such as:
=> next() used to get text data
=> nextInt() used to get integer numbers
=> nextFloat() used get float numbers
=> nextDouble() used to get double numbers
---------------------------------
Example:
--------------
import java.util.*;
class MyInput
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
int a,c;
System.out.println("Type a Number:");
a=s.nextInt();//
c=a*a;
System.out.println("Square="+c)
}
}
------------------------------------
02/04/2019
--------------
5.2 Getting Data using DataInputStream
-----------------------------------
-> DataInputStream class is found in the package java.io
-> DataInputStream has a method called readLine() which accepts only string data,
if we need numbers we have convert by using parseInt(), parseFloat() or
parseDouble()
-> The use of java.io generates exception that can be handled by using throws
IOException or try and catch
------------------------------------------------------
Example:

Written for

Institution
Course

Document information

Uploaded on
June 2, 2021
Number of pages
19
Written in
2020/2021
Type
SUMMARY

Subjects

$7.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
nadegeisimbi

Get to know the seller

Seller avatar
nadegeisimbi university of rwanda
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
4 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions