Module 1
Module 1
(3)
5. Explain JRE.(3)
6. Explain JDK.(3)
7. Garbage Collection.(3)
8. Differentiate between Function Oriented Approach and Object oriented approach.(10)
ABSTRACTION: Abstraction means displaying only essential information and hiding the
details.
POLYMORPHISM: The word polymorphism means having many forms.
Inheritance: The capability of a class to derive properties and characteristics from another
class is called Inheritance.
Inheritance: The capability of a class to derive properties and characteristics from another
class is called Inheritance.
OBJECT
• Objects are real-world entities that has their own properties and behavior.
• It has physical existence
• Eg: person, banks, company, customers etc
CLASS
• A class is a blueprint or prototype from which objects are created
• A class is a generalized description of an object.
• An object is an instance of a class
Relationship between Object & Class
• Let's take Human Being as a class.
• My name is John, and I am an instance/object of the class Human Being
• Object has a physical existence while a class is just a logical definition.
Encapsulation
• The wrapping up of data(variables) and function (methods) into a single unit (called
class) is known as encapsulation.
• It is also called "Information hiding"
• Protection of data from accidental corruption
• Flexibility and extensibility of the code and reduction in complexity
• Encapsulation of a class can hide the internal details of how an object does
something
• Encapsulation protects abstraction
ABSTRACTION
• Abstraction means displaying only essential information and hiding the details.
• Data abstraction refers to providing only essential information about the data to
the outside world, hiding the background details or implementation.
• Consider a real-life example of a man driving a car. The man only knows that
pressing the accelerators will increase the speed of the car or applying brakes will
stop the car but he does not know about how on pressing accelerator the speed is
actually increasing, he does not know about the inner mechanism of the car or the
implementation of accelerator, brakes etc in the car. This is what abstraction is.
POLYMORPHISM
• The word polymorphism means having many forms In simple words, we can define
polymorphism as the ability of a message to be displayed in more than one form.
• Eg: A person at the same time can have different characteristic. Like a man at the
same time is a father, a husband, an employee. So the same person posses
different behavior in different situations. This is called polymorphism.
• An operation may exhibit different behaviors in different instances. The behavior
depends upon the types of data used in the operation.
Inheritance
• The capability of a class to derive properties and characteristics from another class
is called Inheritance.
• Inheritance is the process by which objects of one class acquired the properties of
objects of another classes
• Sub Class: The class that inherits properties from another class is called Sub class or
Derived Class.
• Super Class: The class whose properties are inherited by sub class is called Base
Class or Super class.
• Reusability: Inheritance supports the concept of "reusability", i.e. when we want to
create a new class and there is already a class that includes some of the code that
we want, we can derive our new class from the existing class. By doing this, we are
reusing the fields and methods of the existing class.
• Eg: Dog, Cat, Cow can be Derived Class of Animal Base Class.
OR
10. Explain lexical issues in Java .(10)
Java Lexical Issues (Java Tokens)
Tokens
• Java Tokens are the smallest individual building block or smallest unit of a Java
program
• Java program is a collection of different types of tokens, comments, and white
spaces.
Keywords
• A keyword is a reserved word. You cannot use it as a variable name, constant name
etc.
• The meaning of the keywords has already been described to the java compiler.
These meaning cannot be changed.
• Thus, the keywords cannot be used as variable names because that would try to
change the existing meaning of the keyword, which is not allowed.
• Java language has reserved 50 words as keywords.
Identifiers
• Identifiers are the names of variables, methods, classes, packages and interfaces
• Identifier must follow some rules.
• All identifiers must start with either a letter( a to z or A to Z) or currency
character($) or an underscore.
• They must not begin with a digit
Eg: int a; char name;
Constants or Literals
• Constants are fixed values of a particular type of data, which cannot be modified in
a program.
• Java language specifies five major type of literals.
Eg: Integer literal: 100
Floating-point literal: 98.6
Character literal: 's'
String literal: "sample"
Comments
String
• Brackets[]: Opening and closing brackets are used as array element reference. These
indicate single and multidimensional subscripts.
• Parentheses(): These special symbols are used to indicate function calls and function
parameters.
• Braces(): These opening and ending curly braces mark the start and
• end of a block of code containing more than one executable statement. semicolon;: It is
used to separate more than one statements like in for loop is separates initialization,
condition, and increment.
• Comma: It is an operator that essentially invokes something called an initialization list.
• asterisk: It is used for multiplication.
• assignment operator : It is used to assign values.
• Period: Used to separate package names from subpackages and classes
13. Construct a UML. Activity diagram for Food Ordering System, which shows the flows
between the activity of Order, Delivery, Food Item, Category, Payment.(7)