100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Java summary for beginners $7.49   Add to cart

Summary

Java summary for beginners

 2 views  0 purchase
  • Course
  • Institution

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.

Preview 3 out of 19  pages

  • June 2, 2021
  • 19
  • 2020/2021
  • Summary
avatar-seller
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:

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller nadegeisimbi. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $7.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

76800 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$7.49
  • (0)
  Add to cart