Comp._8th II term
Comp._8th II term
Networks:-
Network – Number of things connected with each other
Computer Network – Collection of interconnected computers that are euipped to
exchange information and share resources with each other.
Advantages: Resource sharing, Reliability, Financial benefits, Better communication,
Access to a remote database, Improved storage capacity
Componenets: Sender(Server), Receiver(Client) and Media
Server: A computer or a program that manages access to shared resources of a network
Client/Workstation: Any computer connected to the server
Wired Networking Technology:
Co-axial Cables – Consistes central copper wire surrounded by a conductive sleeve
separated by an insulator – Cable TV networks – a) Baseband cable – One signal at a time
b) Broadband cable – Multiple signals
Ethernet Cables – Connects network devices – 8 wires(4 for data transfer and 4 for
internet) – a) Patch cables- computer to a hub/switch, b) Crossover cables- Two computers
without a hub/switch
Optical Fibre Cables – Thin strand of light-conducting glass fibre – Data transferred as
a light signal – Can transmit voice, video and coded data in the form of light signals at high
speed.
Online File Sharing Service – Is a way to store and access information in the cloud
rather than locally on a hard disk drive. Ex: OneDrive, Google Docs, YouTube Videos.
Web 2.0 – Internet tools that allow the user to receive information through web and also
interact and create content with others. Ex: Facebook, Twitter, YouTube and Flickr
OneDrive (Windows Live SkyDrive) – Is a password-protected storage area in the
cloud, like an online hard disk. Host- Microsoft Corporation
YouTube – Allows prople to discover, watch and share self-created videos. Founders are:
Steve Chen, Chad Hurley and Javed Karim. Started in Febraury 2005. First video posted
by Javed Khan in April 2005, 18 seconds, ‘Me at Zoo’. Google purchased this in 2006
($1.65 billion). 24 hours of video every minute and user spends at least 15 minutes daily
on YouTube.
3. Introduction to Java:-
Is a platform independent
First released by Sun Microsystems in May 1995
Current owner of Java is Oracle Corporation (taken over in January 2010)
Creators: James Gosling, Patrick Sheridan and James Naughton
It needs IDE (Integrated Development Environment) to run
IDE’s are Java Netbeans, BlueJ, Eclipse and IntelliJ
OBJECT ORIENTED PROGRAMMING - A different and modern approach to
programming that is based on the fundamental concepts of objects. Ex: C++, Python
and Java.
OBJECT – It is the basic element of OOP which has well defined characterstics, properties
and behaviour.
When you invoke methods, it will request for the additional information of that method
which are called attributes or formal parameters in Java.
The value of an attribute is called an argument or an actual parameter.
The set of arguments or atributes or actual parameters of an object is called the state of
that object.
CLASS – A class can be understood as a collection of similar objects. As a convention,
we start class names with uppercase letters and object names with lowercase letters.
DATA HIDING – A variable can be declared as private or public. A private variable is
accessible only within the class in which it is declared. A public variable is accessible to
all the classes in the program.
INHERITANCE – When one object acquires the properties and behavious of a parent
object, its is known as inheritance. Hierarchical relationship.
POLYMORPHISM – Poly mean many and morphism means forms. When the same
method can be invoked for different purposes, it is known as polymorphism. In Java,
polymorphism is used to implement inheritance.
ENCAPSULATION – Binding or wrapping code and data together into a single unit is
called encapsulation. Ex: Java class.
DATA ABSTRACTION – Hiding internal details and revealing only the essential
functionality is known as abstraction.
STARTING BLUEJ - Start All Programs BlueJ BlueJ or Double click the BlueJ icon on the
desktop
WRITING A JAVA PROGRAM –
Click Project New Project
New Project dialog box appears Folder name text box Click create
BlueJ: Sample window New Class BlueJ: Create New Class dialog box Enter name &
click OK.
COMPILING A JAVA PROGRAM – Means to convert the source code to object code. A
compiler is a program that translates Java code into machine code.
KEYWORDS – They are reserved words that have a predefined meaning in the
programming language.
DATA TYPES – Each variable in a program must be given a data type, i.e., the type of
data it can store.
LITERALS – Literals or Constants refer to fixed values that do not change during the
execution of a program.
Integer Constant- Is a whole number with positive/negative values.
Floating-point Constant- Is a number with decimal point having positive/negative
values
Character Constant- Represents letters in upper/lower case, digits and special
characters.
It is single character enclosed in single quotes ( ‘ ‘ ).
String Constant- Consists of more than one character enclosed in doube quotes ( “ “).
VARIABLES – Is a portion of memory used to store a value.
RULES –
It can one or more letters ( a to z or A to Z), digits ( 0 to 9 ) or underscore characters
Should begin with a letter, underscore or dollar ($) character
Uppercase and lowercase letters are distinct
Identifiers or variables cannot be a keyword.
Declaration of Variables: The type of a variable decides the value it will store.
Initializaing a Variable: The method of assigning a value and defining the data type
at the same time is called initialization. If you decalre the variable and do not initialize it, it
will take a garbage value (unknown value).
OPERATORS – Are used for performing operations on constants and variable. The
variables and constants are called operands. Operators and operands together form an
expression.
ARITHMETIC OPERATORS – ( +, -, *, /, % )
Parentheses ( )
Unary operators ( +, - )
Exponent ( ^ )
Multiplication ( * ), Division ( / ), Modulus ( % )
Addition ( + ), Subtraction ( - )
RELATIONAL OPERATORS ( ==, !=, >, <, >=, <= ) - Used to compare two
expressions. Result is a boolean value.
LOGICAL OPERATORS ( &&, || , ! ) – Precedence is !, && and then ||
COMPOUND ASSIGNMENT OPERATORS – ( +=, -=, /=, *=, %= )
LOOPING STATEMENTS: -
for Loop – Entry-controlled loop.
for ( initialization; condition; increment/decrement)
statement(s)
while Loop – Entry-controlled loop.
initialization;
while (condition)
{
statement(s);
increment/decrement;
}
do… while Loop – Exit-controlled loop.
Initialization;
Do
{
statement(s);
increment/decrement;
} while (condition);
Factorial of 5 using for Loop
public class Facrorial5
{
public static void main()
{
int i, fact=1;
int number=5;
for(i=1; i<=number; i++)
fact=fact*i;
System.out.println("Factorial of "+ number +" is: "+ fact);
}
}