0% found this document useful (0 votes)
12 views7 pages

Summary of Chapter 1 To 5

The document summarizes the first five chapters of a Java programming textbook, covering types of Java programs, features of Java, and fundamental concepts such as object-oriented programming, encapsulation, inheritance, and polymorphism. It explains the structure of Java code, including data types, variables, operators, and expressions, as well as input handling using the Scanner class. Additionally, it discusses the importance of comments, constants, and the Java character set.
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)
12 views7 pages

Summary of Chapter 1 To 5

The document summarizes the first five chapters of a Java programming textbook, covering types of Java programs, features of Java, and fundamental concepts such as object-oriented programming, encapsulation, inheritance, and polymorphism. It explains the structure of Java code, including data types, variables, operators, and expressions, as well as input handling using the Scanner class. Additionally, it discusses the importance of comments, constants, and the Java character set.
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/ 7

Summary of Chapter 1 to 5

[Refer Textbook for examples wherever required]

 Types of Java Programs: Applications and Applets.

 Stand alone application : this type of programs are written to carry out specific tasks on a
stand-alone local Computer.

 Applet programs :are used in internet applications. The java applet will be placed on the
web by embedding into a HTML file.

 Source code is the set of instructions and statements written by a programmer using a
computer programming language

 Object code is produced when an interpreter or a compiler translates source code into
recognizable and executable machine code.

 Byte code is program code that has been compiled from source code into low-level code
designed for a software interpreter. It may be executed by a virtual machine (such as a
JVM) or further compiled into machine code.

 Features of Java: Simple language, compiled and interpreted, robust and secure, platform
independent, Architecture neutral, Distributed, Multithreaded, Object Oriented, Garbage
collection etc.,

 Java solves the problem of platform independence by using byte code.


 Procedural Oriented Program organizes the program around its code.
 Object Oriented Program organizes the Program around its data.
 A software object maintains its state in one or more variables.
 A software object implements its behavior with methods.
 A particular object is called an Instance.
 The methods of a class are formally known as instance method.
 During program execution one object passes and receives information from another
object using member functions. Such process is called Data messaging.
 The two primary benefits of encapsulation are Modularity and information hiding.
 One of the main advantage of inheritance is any data member can be reused without
defining.
 An object factory is a producer of objects.
 A class is a set of objects that have common structure and common behavior.
 An object is identified by its attributes.
 An object is a software bundle of variables and related functions.
 A class is a blueprint or prototype of objects. Group of objects form a class. A class
defines variables and methods common to all the objects.
 Abstraction is to represent essential features of a system without getting involved with the
complexity of the entire system.
 Encapsulation is the mechanism that binds code and data together it manipulates. Two
primary benefits of encapsulation are modularity and information hiding.
 Polymorphism allows two or more classes to respond to the same message in different
ways.
 Inheritance is the process by which one object acquires the properties of another object.
The class whose property is acquired is called BASE class. The class in which the
property of BASE class is acquired is called DERIVED class. The different types of
inheritance are as follows:
 Simple or Single inheritance which contains one BASE class and one DERIVED
class.
 Multilevel inheritance is the inheritance in which classes are derived in a sequential
order.
 Multiple inheritance is the inheritance in which there are many base classes and one
derived class.
 Hybrid inheritance is the combination of both multilevel and multiple inheritance.
 Hierarchical inheritance is the inheritance in which classes are derived in hierarchical
manner.
 The keyword extends is used to derive the property from base class to derived class.
 Software objects interact and communicate with each other using messages, messages
are passed as parameters using the function.
 System.out.print () - displays the result and the cursor remains in the same line.
 System.out.println () - displays the result and the cursor moves to the next line.
 Every individual unit in a program is called a Token.
 White space is a space between two tokens. It is also called as a tab, space or newline.
 Keywords are reserved words that convey special meaning to the compiler.
 Identifiers are the names given to various data items in a program such as variables,
class names, function/method names, object names.
 An identifier can start with an alphabet (uppercase or lowercase).
 An identifier can have only $ and _ as special characters.
 An identifier can numbers between or at the end of identifier.
 No blank space allowed while naming the identifier.
 Java keywords must not be used for naming the identifiers.
 A comment is a remark from the programmer to explain some aspect of the code to
someone who is reading the source code.
 Types of comments: Single line, multi-line and documentation comments.
 Separators are used as punctuation marks in a program such as ;(semicolon) to end the
java statement, comma(,) to separate variables etc.,
 Constants or literals are the data items which does not change their values during the
execution of the program. The different types of constants are Integer, Floating point,
Character, String, and Boolean literals.
 A data type is a set of possible values that a variable can hold. The various size and
ranges of different data types are shown below:-

Data type Size in bits Size in bytes


byte 8 bits 1 byte
short 16 bits 2 bytes
int 32 bits 4 bytes
long 64 bits 8 bytes
float 32 bits 4 bytes
double 64 bits 8 bytes
char 16 bits 2 bytes
boolean 8 bits, but uses 1 bit 1 byte
 A variable is a named memory location to store values.
 Declaration of a variable is the data type followed by the name of a variable.
 Initialization of a variable is nothing but storing values using assignment operator =.
 Dynamic initialization of a variable means assigning values during the execution of
the program.
 Java character set is a 2-byte character code set. It can represent 65536 characters,
which means almost all human alphabets and writing symbols around the world can be
represented.
 ASCII character set is a 1 byte character code set, it can represent only 128 characters.
The various ASCII values range are A-Z(65-90), a-z(97-122), 0-9(48-57).
 An operator is a symbol used to perform specific operation on operands.
 Operators are classified into Unary, Binary and Ternary Operators.
 Operators that holds two operands are called Binary Operators.
 Operators that hold only one operand are called Unary Operator.
 Operator that holds three operands is called Ternary operator.
 Arithmetic operators (Binary operators) are used to perform arithmetic operations on
two or more variables (operands) or values. The symbols used are + (Addition),
- (Subtraction), * (multiplication), / (division, returns quotient as output), % (Modulo),
returns remainder as output). The result of these operators will be either integer, or
float, or double data type.
 Relational operators are used to check the relationship between two operands.
Symbols used are < (less than), > (greater than), <= (less than or equal to), >= (greater
than or equal to), = = (equal to),!= (Not equal to). The result of these operators is a
boolean value either true or false.
 Logical operators are used to check the relation between two or more relational
expressions and give the result in boolean data type. The symbols used are & (AND), |
(OR) ! (NOT),
 Short-circuit operators are used to check the relation between two or more relational
expressions conditionally and give the result in boolean data type. The symbols used
are && (AND), ||(OR). Conditionally means, In case of &&, if the first expression is
true then it checks the second expression otherwise not. In case of ||, if the first
expression is false then it checks the second expression, otherwise not.
 Unary operators are the operators that hold only one operand. The symbols are +
(Unary plus which indicates it is a positive value. It is also used to promote the value
to int if it is in byte or short or char), -(Unary minus indicates the number is negative),
++(Increment), --(Decrement).
 Assignment operators are used to assign values to variables during compilation or
execution of the program. The different types of assignment operators are simple
assignment (=), compound assignment (a=b=c=d=……… where all the operands
should be of same data type), complex or short hand assignment (+=, -=, *=, /=, %=).
 Ternary operator is used to replace if else statements. It contains three expressions.
The symbols used are ? and :
 An operator between two operands is called infix notation.
 An operator present before the operand is called prefix notation.
 An operator present after the operand is called postfix notation.
 Expression is the combination of operators and operands. The two types of expression are
pure expression or complex expression and impure expression or mixed mode
expression..
 In pure expression all the operands in an expression belongs to the same data type.
 In Impure expression all the operands or any one operand belongs to different data type.
 Operator precedence/hierarchy determines the order in which operands are executed in an
expression based on the priority given to the operator associated with it. [Note: learn the
priority order table given in the text book]
 Operator associativity determines the order of evaluation either from left to right or right
to left, when more than one operator has the same priority.
 The process of converting one primitive type to another is called type conversion. The
two types of conversion are Implicit or widening or Automatic or COERCION and
Explicit conversion or Narrowing or type casting.
 Implicit conversion is the conversion of one primitive type to another compatible
primitive type done by the java compiler without programmer’s intervention.
 Explicit conversion is the conversion from one primitive type to another type using type
cast operator ( ) done by using programmer’s intervention.
 Conditions of Implicit conversion are: (1) Two type are compatible. (2) The destination
type is larger than the source type.
 Conditions of Explicit conversion are: (1) Two types are incompatible. (2) The
destination type is less than the source type.
 Escape sequence or Non-graphic characters are used in java to format the output.
\nnew line, \t tab space, \” prints double quotes, \’ prints single quote, \\ prints a
slash(\).
 final keyword is used to define the value of a variable always constant throughout the
program. Example: final int a=10;
 Scanner class looks for tokens in the input. A token is a series of characters that ends with
whitespace. A whitespace character can be blank, a tab character, or the end of the line.
 Scanner class belong to java.util package.
 The keyword import is used to call a package.
 Creating a Scanner object as Scanner ob=new Scanner(System.in);
 Strings can also be passed as input to scanner object as Scanner ob=new
Scanner(“Welcome to Scanner class”);
 Accepting input for various data types:
Scanner ob=new Scanner(System.in);
System.out.println (“Enter an integer”);
int a=ob.nextInt( );
System.out.println (“Enter a float value”);
float b=ob.nextFloat( );
System.out.println (“Enter a double value”);
double c=ob.nextDouble( );
System.out.println(“Enter a long value”);
long d=ob.nextLong( );
System.out.println(“Enter a string”);
String e=ob.next( );
System.out.println(“Enter a sentence”);
String f=ob.nextLine( );
System.out.println(“Enter a character”);
char g=ob.next( ).charAt(0);

nextInt() is used to read integer values from the scanner object.


nextFloat() and nextDouble() is used to read decimal values from the scanner object.
nextLong() is used to read long integers from the scanner object.
next() is used to read a string upto the space character from the scanner object.
nextLine() is used to read string tokens till it finds the new line \n character.
nextBoolean() is used to accept true/false.
In addition to the above , you must know the use of the following Math functions:-
(1) sqrt() (2) pow() (3) cbrt() (4) abs() (5) max() (6) min()
____________

You might also like