II-II SEM JAVA PROGRAMMING COURSEFILE(2020-21) (1)
II-II SEM JAVA PROGRAMMING COURSEFILE(2020-21) (1)
PROGRAMMING
Mr.J SRIKANTH
Assistant Professor
COURSEFILE (2022-2023)
Department of
Computer Science and Engineering
BRILLIANT INSTITUTE OF ENGINEERING & TECHNOLOGY
(Sponsored by: Brilliant Grammar School Educational Society)
(Approved by AICTE, New Delhi, Affiliated to JNTU-Hyderabad)
Abdullapur (V), Abdullapurmet (M), R.R. Dist – 501505, Telangana, India
CONTENT LIST
Sl.
Content
No.
1. Vision & Mission
2. Program Educational objectives, Program Outcomes, Program Specific Outcomes
3. Syllabus copy
4. Course Objectives & Course Outcomes
5. Instructional Learning Outcomes
6. Course mapping with PEOs and PSO,PO
7. JUNTUH & Department calendar
8. Class Time Tables
9. Individual Time Tables
10. Content beyond Syllabus
11. Gaps Identification
12. Guest Lecture Conducted
13. Micro lecture plan
Unit-wise Short and Long Answer Questions (Minimum 10 from Each unit,
14.
Mapping with BTL and COs)
15. Unit wise Quiz Questions (With Key)
16. Assignment Questions and Mapping with BTL Levels and COs
17. Tutorial Questions and Mapping with BTL and COs
18. References, Websites and E-Links
19. University Question Papers of Previous Years
20. Quality Control Sheets
a. Student List
b. Assignment Test-1 Question paper
c. Mid-1 Question paper, Marks Sheet
d. Slow Learners
e. Time Table of Makeup Classes for Slow Learners
f. Assignment-2 question papers
g. Mid-2 Question paper, Marks Sheet
21 Lecture notes
22 CO’s Attainment (Based on internal and external evaluation)
To empower students with professional education using creative & innovative technical practices
of global competence and research aptitude to become competitive engineers with ethical values
and entrepreneurial skills.
To impart value based professional education through creative and innovative teaching-learning
process to face the global challenges of the new era technology.
To inculcate research aptitude and to bring out creativity in students by imparting engineering
knowledge imbibing interpersonal skills to promote innovation, research and entrepreneurship.
Vision o
Debouch as a centre of excellence for computer science engineering by imparting social, moral and
ethical values oriented education through advanced pedagogical techniques and produce
technologically and highly competent professionals of global standards with capabilities of solving
challenges of the time through innovative and creative solutions.
Mission
To envision inquisitive-driven advanced knowledge building among students to impart foundational
knowledge of computer science and its applications of all spheres using the state-of-the-art facilities
and software industry-institute interaction.
To advance the department industry collaborations through interaction with professional society
through seminars/workshops/guest lectures and student internship programs.
To nurture students with leadership qualities, communication skills and imbibe qualities to work as a
team member and a leader for the economical and technological development in cutting edge technolo-
gies in national and global arena.
PEO1: To provide graduates the foundational and essential knowledge in mathematics, science, computer
science and engineering and interdisciplinary engineering to emerge as technocrats.
PEO2: To inculcate the capabilities to analyze, design and develop innovative solutions of computer sup-
port systems for benefits of the society, by diligence and teamwork.
PO1: Engineering Knowledge: Apply the knowledge of mathematics, science, engineering fundamentals
and an engineering specialization to the solution of complex engineering problems.
PO2: Problem Analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences and
Engineering sciences.
PO3: Design/Development of Solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the public
health and safety, and the cultural, societal, and environmental considerations.
PO4: Conduct Investigations of Complex Problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of the
information to provide valid conclusions.
PO5: Modern Tool Usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an
understanding of the limitations.
PO6: The Engineer and Society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.
PO7: Environment and Sustainability: Understand the impact of the professional engineering solutions
in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.
PO8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering practice.
PO9: Individual and Team Work: Function effectively as an individual and as a member or leader in
diverse teams, and in multidisciplinary settings.
PO10: Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and
design documentation, make effective presentations, and give and receive clear instructions.
PO11: Project Management and Finance: Demonstrate knowledge and understanding of the engineering
management principles and apply these to one's own work, as a member and leader in a team, to manage
projects and in multidisciplinary environments.
PO12:Life-long Learning: Recognize the need for and have the preparation and ability to engage in
independent and lifelong learning in the broadest context of technological change.
UNIT -II Packages- Defining a Package, CLASSPATH, Access protection, importing packages.
Interfaces- defining an interface, implementing interfaces, Nested interfaces, applying interfaces, variables
in interfaces and extending interfaces.
Stream based I/O (java.io) – The Stream classes-Byte streams and Character streams, Reading console
Input and Writing Console Output, File class, Reading and writing Files, Random access file operations,
The Console class, Serialization, Enumerations, auto boxing, generics.
UNIT - III Exception handling - Fundamentals of exception handling, Exception types, Termination or
presumptive models, Uncaught exceptions, using try and catch, multiple catch clauses, nested try
statements, throw, throws and finally, built- in exceptions, creating own exception sub classes.
Multithreading- Differences between thread-based multitasking and process-based multitasking, Java
thread model, creating threads, thread priorities, synchronizing threads, inter thread communication.
UNIT - IV The Collections Framework (java.util)- Collections overview, Collection Interfaces, The
Collection classes- Array List, Linked List, Hash Set, Tree Set, Priority Queue, Array Deque. Accessing a
Collection via an Iterator, Using an Iterator, The For-Each alternative, Map Interfaces and Classes,
Comparators, Collection algorithms, Arrays, The Legacy Classes and Interfaces- Dictionary,
Hashtable,Properties, Stack, Vector More Utility classes, String Tokenizer, Bit Set, Date, Calendar,
Random, Formatter, Scanner
UNIT - V GUI Programming with Swing – Introduction, limitations of AWT, MVC architecture,
components, containers. Understanding Layout Managers, Flow Layout, Border Layout, Grid Layout, Card
Layout, Grid Bag Layout.
Event Handling- The Delegation event model- Events, Event sources, Event Listeners, Event classes,
Handling mouse and keyboard events, Adapter classes, Inner classes, Anonymous Inner classes
. A Simple Swing Application, Applets – Applets and HTML, Security Issues, Applets and Applications,
passing parameters to applets. Creating a Swing Applet, Painting in Swing, A Paint example, Exploring
Swing Controls- JLabel and Image Icon, JText Field, The Swing Buttons- JButton, JToggle Button, JCheck
Box, JRadio Button, JTabbed Pane, JScroll Pane, JList, JCombo Box, Swing Menus, Dialogs.
TEXT BOOKS
1. Java The complete reference, 9th edition, Herbert Schildt, McGraw Hill Education (India) Pvt. Ltd. 2.
Understanding Object-Oriented Programming with Java, updated edition, T. Budd, Pearson Education.
REFERENCE BOOKS
1. An Introduction to programming and OO design using Java, J. Nino and F.A. Hosch, John Wiley &
sons.
2. Introduction to Java programming, Y. Daniel Liang, Pearson Education.
3. Object Oriented Programming through Java, P. Radha Krishna, Universities Press.
4. Programming in Java, S. Malhotra, S. Chudhary, 2nd edition, Oxford Univ. Press.
5. Java Programming and Object oriented Application Development, R. A. Johnson, Cengage Learning.
Course Outcomes:
Able to solve real world problems using OOP techniques.
Able to understand the use of abstract classes.
Able to solve problems using java collection framework and I/o classes.
Able to develop multithreaded applications with synchronization.
Able to develop applets for web applications.
Able to design GUI based applications
Unit-II
1. Apply the Concepts of inheritance, Polymorphism and Interfaces and Packages
2. Design abstract classes and interfaces and analyze when to use them.
2. Create and access a package.
Unit-III
1. Handle Exceptions and create own exception sub classes.
2. Multithread programming with an ability to synchronize threads.
Unit- IV
1. Use the Collection Frame work in java.
2. File management with a clear understanding of different kinds of input output streams
3. Connecting and querying a database using JDBC
Unit-V
1. Design GUI screens using AWT and Swings
2. Handle different types of events
3. Design Applets
UNIT - III
1 Define Exception? Understand
2 Distinguish between exception and error? Understand
3 Write benefits of exception handling Understand
4 Write the classification of exceptions Understand
5 Define checked exceptions? Understand
6 Define unchecked exceptions? Understand
7 Define built in exceptions? Understand
8 Write the usage of try and catch Understand
9 Write the usage of throw, throws and finally Understand
10 Distinguish between throw and throws? Understand
11 Distinguish between process and thread? Understand
12 Write thread states Understand
13 Write creation of thread? Understand
14 Define producer consumer problem? Understand
15 Define inter-thread communication? Understand
16 Write How threads are synchronized? Understand
17 Write thread priorities Understand
18 How many ways can thread be Created? Understand
19 Write the alive() and join() method Understand
20 Write thread class implements Runnable interface Understand
UNIT – IV
1 Define collections? Understand
2 Define Java collection Frame work. Understand
3 Define Array List with syntax Understand
4 Define Vector with syntax. Understand
5 Define hash table with syntax. Understand
6 Define stack with syntax. Understand
7 Define enumeration with syntax. Understand
8 Write Iterator. Understand
9 Write the function of stringTokenizer. Understand
10 Define random class. Understand
11 Define Scanner class. Understand
12 Define Calendar class. Understand
13 Define Properties class Understand
14 Define Stream? Understand
15 Define byte stream? Understand
16 Define character stream? Understand
17 Define text input/output file? Understand
18 Define Map Interface. Understand
19 List legacy classes in CFM. Understand
20 Define random access file? Understand
UNIT - V
1 Define AWT class hierarchy? Understand
2 Distinguish between swings Vs AWT? Understand
3 Write hierarchy for swing? Understand
4 Define components? Understand
5 Define containers? Understand
6 Define JFrame, JApplet, JDialog and Jpanel? Understand
7 Define some of swing components? Understand
8 Define Jbutton, JLabel, JTextField and JtextArea? Understand
9 Define Layout management? Knowledge
10 List Layout manager types – border and grid flow? Understand
11 Write Events, Event sources, Event classes Understand
12 Write Event Listeners Understand
13 Describe the relationship between Event sources and Listeners? Understand
14 Define Delegation event model? Knowledge
15 Describe events for handling a button click? Understand
16 Describe events for handling mouse events? Understand
17 Define adapter class? Knowledge
18 Distinguish between applet and application? Understand
19 Write applet life cycle Understand
20 Describe applet security issues? Understand
UNIT – II
1 Define Inheritance? Discuss its uses and Hierarchical abstractions? Knowledge
2 List types of inheritances in java? Write each of them in detail. Understand
3 Write about Object class in detail Understand
4 Write Uses of ‘Super’ keyword , discuss accessing the member of a Understand
super class
S. No Question Blooms
Taxonomy Level
Unit-1(10Questions)
Answer all Questions 10 X 0.5 = 5
Part-A
1 Which of the following is not a key component of Object Oriented Programming? [D]
A Inheritance B Encapsulation C Polymorphism D Parallelism
2 Which of these is TRUE of the relationship between object and classes? [C]
A class is an An object is the An object is an An Object is the
A instance of an B ancestor of its C instance of a D descendant of its
object subclass class super class
Which operator is used by java runtime implementations to free the memory of object when it is
3 [D]
no longer needed
A Delete B free C new D None of these
4 The reference of an object is created using -------keyword [A]
A This B static C new D class
5 Which of these keywords is used to refer to member of base class from subclass? [B]
A Upper B super C this D that
6 Which of these keywords is used to prevent content of a variable from being modified? [A]
A Final B static C const D abstract
7 ----is the process of using same name for two or more functions [ D ]
Method Constructor Constructor Method
A B C D
Overriding overloading overriding overloading
8 Which of these have highest precedence [A]
A () B ++ C * D >>
9 -----is used to find length of an array [ A]
A Length B length() C sizeof() D None of these
10 What is the process of defining a method in terms of itself that is a method that calls itself? [D]
A Polymorphism B Abstraction C Encapsulation D Recursion
1 Which of these can be used to fully abstract a class from its implementation? [C]
None of the
A Objects B Packages C Interfaces D
Mentioned
2 Which of these keywords is used by a class to use an interface defined previously? [C]
A Import B Import C implements D implements
3 Which one is correct declaration for implementing two interfaces? [A]
class C impleme class C implem
class C impleme None of the
A B nts A, impleme C ents A extends D
nts A, B Mentioned
nts B B
Which of this access specifies can be used for a class so that its members can be accessed
4 [ D]
by a different class in the same package?
All of the
A Public B protected C No modifier D
Mentioned
5 Which of the following is correct way of importing an entire package ‘pkg’? [ D]
A Import pkg. B import pkg. C Import pkg.* D import pkg.*
6 Which of the following package stores all the standard java classes? [C]
A Lang B util C java D io
7 The first statement in java source file [ B]
package
A import statement B C main statement D try{}catch{}
statement
8 Which of these class is not related to input and output stream in terms of functioning? [ A]
A File B InputStream C Reader D OutputStream
9 Which of these interface is not a member of java.io package [ C]
A DataInput B ObjectInput C ObjectFilter D FileFilter
10 Which of these is a method to clear all the data present in output buffers? [ C]
A clear() B fflush() C flush() D close()
9 What is the name of the method used to start a thread execution? [B]
Which is the container that doesn't contain title bar and MenuBars but it can have other
1 [C]
components like button, textfield etc?
A Window B Frame C Panel D Container
2 Give the abbreviation of AWT? [B]
Applet Abstract Absolute
None of the
A Windowing B Windowing C Windowing D
above
Toolkit Toolkit Toolkit
3 Which object can be constructed to show any number of choices in the visible window? [ C ]
A Labels B Choice C List D Checkbox
4 Which of these functions is called to display the output of an applet? [ B ]
A display() B paint() C displayApplet() D PrintApplet()
5 Which of these methods can be used to output a string in an applet? [ C ]
A display() B print() C drawString() D transient()
Which of these packages contains all the classes and methods required for even handling in
6 [ D]
Java?
A java.applet B java.awt C java.event D java.awt.event
7 Which of these methods are used to register a mouse motion listener? [C]
addMouseListen addMouseMotio eventMouseMot
A addMouse() B C D
er() nListner() ionListener()
8 Which of these events is generated when a button is pressed? [ A]
AdjustmentEve
A ActionEvent B KeyEvent C WindowEvent D
nt
9 Which of these events is generated when the size of an event is changed? [A]
A ComponentEvent B ContainerEvent C FocusEvent D InputEvent
10 Which of these events is generated when computer gains or loses input focus? [ C ]
A ComponentEvent B ContainerEvent C FocusEvent D InputEvent
Assignment-2
1. Write a Java Program to demonstrate Method overriding.
2. Write a Java Program demonstrate the Use of “super” keyword.
3. Write a Java Program to create Geometric shape interface with methods area( ) and perimeter( ) for
classes triangle ,rectangle and circle. \
4. Write a Java Program to demonstrate Packages containing package name as “sortapp” a in which de-
clare an interface “sortInterface” with method sort() whose return type and parameter type should be
void and empty define “subsortapp “ as subpackage of “sortapp” package in which define a class.
5. Write a Java Program to Sort a given list of names in ascending order.
6. Write a Java Program to represent bank account containing Account number account name and balance
and methods as Deposit and withdraw.
7. Write a Java Program to demonstrate Single inheritance.
8. Write a Java Program to demonstrate Static keyword.
9. Design and develop a java program to show abstract methods
Assignment-3
1. Write a Java Program Method to throw “insufficient fund exception” in withdraw method of bank ac-
count class.
2. Write a Java Program to define two threads such that one thread prints even numbers and another
thread prints odd numbers.
3. Write a Java Program to demonstrate Synchronization concept.
4. Design and develop a java program to create three threads the first thread prints ‘good morning’ for
every one second ,the second thread prints ‘hello!’ for every 2 seconds and the third thread prints ‘wel-
come’ for every three seconds.
5. Write a Java Program to demonstrate Event handling.
6. Write a Java Program to demonstrate Try-catch-finally all in one program.
7. Design and develop a java program for creating our own Exception class. In this the details of account
number, customer name and balance amount in the form of 3arrays the in main() method we display
these details using for loop. at this time we check if any account balance is less than 1000/- the MyEx-
ception is raised and a message is displayed like’ balance is less than 1000/-“.
Assignment-5
1. Write a Java Program to demonstrate Choice.
2. Write a Java Program to demonstrate Menu Bar.
3. Design and develop a java program to create an applet and display a simple message like “Hello!
Welcome to Applet Programming”.
4. Write a java program that simulates a traffic light. The program lets the user select one of three lights:
red, yellow, or green. When a radio button is selected, the light is turned on, and only one light can be on
at a time No light is on when the program starts.
5. Write a Java program that allows the user to draw lines, rectangles and ovals.
6. Design and develop a java program to show the use Calendar class
7. Write a Java program that works as a simple calculator. Use a grid layout to arrange buttons for the
digits and for the +, -,*, % operations. Add a text field to display the result.
8. Write a program that creates a user interface to perform integer divisions. The user enters two num-
bers in the textfields, Num1 and Num2. The division of Num1 and Num2 is displayed in the Result field
when the Divide button is clicked. If Num1 or Num2 were not an integer, the program would throw a
NumberFormatException. If Num2 were Zero, the program would throw an ArithmeticException Dis-
play the exception in a message dialog box.
Tutorial-2
1. Write a Java Program to demonstrate Widening conversion.
2. Write a Java Program to demonstrate Method chaining.
3. Write a Java Program to demonstrate String tokenizer class methods.
Tutorial-3
1. Write a Java Program to demonstrate Dynamic method dispatch (class program).
2. Write a Java Program to check whether a String is palindrome or not.
3. Write a Java Program to Count number of words in a given text.
4. Write a Java Program To print Fibonacci sequence up to a given number.
5. Write a Java Program to demonstrate Final keyword.
6. Design and develop how to create a package and how to import the packages in java.
Tutorial-4
1. Write a Java Program to demonstrate Thread priority.
2. Write a Java Program to simulate a simple calculator
3. Write a Java Program to demonstrate Thread priority.
Tutorial-5
1. Design and develop a java program to how to handle ArithmeticException and ArrayIndexOutOf-
BoundsException by use try, catch and finally blocks.
2. Design and develop a java program to create three threads the first thread prints ‘good morning’ for
every one second ,the second thread prints ‘hello!’ for every 2 seconds and the third thread prints ‘wel-
come’ for every three seconds
3. Design and develop a java program to show the use of throw keyword for throwing NullPointerExcep-
tion.
Tutorial-6
1. Design and develop a java program that reads a filename and displays the file on screen.
2. Design and develop a java program that reads a filename from keyboard and display the number of
characters in the file.
3. Write a java program to illustrate Stack class.
Tutorial-7
1. Write a Java Program to demonstrate List.
2. Write a Java Program to demonstrate Checkbox.
3. Write a java program to demonstrate passing parameters to Applets.
4. Develop an applet that receives an integer in one text field, and computes its factorial Value and returns
it in another text field, when the button named “Compute” is clicked.
Tutorial-8
Tutorial -9
1. Design and develop a java program to demonstrate the creation of thread groups.
2. Design and develop a java program to create multiple threads and make the threads to act on a single
object using Synchronization block .
3. Design and develop a java program to show how to handle checked exceptions.
4. Design and develop a java program to demonstrate on inter-thread communication for producer-con-
sumer problem.
5. Write a Java program for handling mouse events
1. An Introduction to programming and OO design using Java, J. Nino and F.A. Hosch, John Wiley & sons.
5. Java Programming and Object oriented Application Development, R. A. Johnson, Cengage Learning.
1. https://www.oracle.com/technetwork/java/oo-140949.html
2. https://www.ibm.com/developerworks/java/tutorials/j-introtojava1/index.html
3. http://www.nptelvideos.com/java/java_video_lectures_tutorials.php?pn=1#
4. https://www.w3resource.com/java-tutorial/java-object-oriented-programming.php
5. https://www.tutorialspoint.com/java/
https://www
.guru99.com/java-oops-concept.html
Assignment-1
2 X 10=20M
Answer all Questions
Blooms Taxon- Marks
Sl. CO
Question omy
No. Mapping
Level
a) What is class? How does it accomplish data hiding?
1 b) Explain the polymorphism and overloading with an example. C01 1,2 10
OR
a) What is a constructor? What are its special properties?
2 b) Elaborate the Uses of ‘Super’ keyword, discuss accessing the CO1 1,6 10
member of a super class
a) Explain the process of importing and accessing a package with
suitable examples. C02 1,2
3 10
b) What do you know about Random Access File?
OR
a) Write about some Java’s built in exceptions with example.
b) Develop a program with nested try statements for handling ex-
4 C03 3 10
ception
Roll Num-
PART-A
Answer all Questions 10 X 0.5 = 5
Part-A
3 Which of these keywords is used to prevent content of a variable from being modified? []
4 _______is the process of using same name for two or more functions []
5 Which of these can be used to fully abstract a class from its implementation? []
None of the
A Objects B Packages C Interfaces D
Mentioned
Protected
A Interfaces B Multithreading C D Private methods
methods
In order to restrict a variable of a class from inheriting to subclass, how variable should
8 []
be declared?
Part-B
The Java interpreter translates a Java program from ____to machine language.byte
1.
code
Assignment-2
c) Mid-2 Question paper, Marks Sheet, Sample copy of Best, Average and Below Average Answer
Scripts:
4 Which object can be constructed to show any number of choices in the visible window? [ C]
A Labels B Choice C List D Checkbox
5 What is the correct method used to insert and delete items from the queue? [B ]
enqueue and de- enqueue and
A push and pop B C D add and remove
queue peek
Which is the container that doesn't contain title bar and MenuBars but it can have other
6 [C ]
components like button, textfield etc?
A Window B Frame C Panel D Container
7 Which object can be constructed to show any number of choices in the visible window? [C ]
A Labels B Choice C List D Checkbox
Which of these packages contains all the classes and methods required for even handling in
10 [ ]
Java?
A java.applet B java.awt C java.event D java.awt.event
Part-B
Fill in the Blanks
1. ___________decides thread priority.Thread Scheduler
3. The interface is used to traverse a list in both forward and backward direction is ________ListIter-
ator
21 - Lecture notes
Unit-1
To solve my food delivery problem, I used a solution by finding an appropriate agent (Zomato) and pass a
message containing my request. It is the responsibility of the agent (Zomato) to satisfy my request. Here, the
agent uses some method to do this. I do not need to know the method that the agent has used to solve my
request. This is usually hidden from me.
So, in object-oriented programming, problem-solving is the solution to our problem which requires the help
of many individuals in the community. We may describe agents and communities as follows.
In our example, the online food delivery system is a community in which the agents are zomato and set of
hotels. Each hotel provides a variety of services that can be used by other members like zomato, myself, and
my family in the community.
To solve my problem, I started with a request to the agent zomato, which led to still more requestes among
the members of the community until my request has done. Here, the members of a community interact with
one another by making requests until the problem has satisfied.
In object-oriented programming, every action is initiated by passing a message to an agent (object), which
is responsible for the action. The receiver is the object to whom the message was sent. In response to the
message, the receiver performs some method to carry out the request. Every message may include any ad -
ditional information as arguments.
In our example, I send a request to zomato with a message that contains food items, the quantity of food,
and the hotel details. The receiver uses a method to food get delivered to my home.
8. Responsibilities
In object-oriented programming, all objects are instances of a class. The method invoked by an object in
response to a message is decided by the class. All the objects of a class use the same method in response to a
similar message.
In our example, the zomato a class and all the hotels are sub-classes of it. For every request (message), the
class creates an instance of it and uses a suitable method to solve the problem.
A graphical representation is often used to illustrate the relationships among the classes (objects) of a
community. This graphical representation shows classes listed in a hierarchical tree-like structure. In this
more abstract class listed near the top of the tree, and more specific classes in the middle of the tree, and the
individuals listed near the bottom.
In object-oriented programming, classes can be organized into a hierarchical inheritance structure. A child
class inherits properties from the parent class that higher in the tree.
In the class hierarchy, both parent and child classes may have the same method which implemented
individually. Here, the implementation of the parent is overridden by the child. Or a class may provide
multiple definitions to a single method to work with different arguments (overloading).
The search for the method to invoke in response to a request (message) begins with the class of this receiver.
If no suitable method is found, the search is performed in the parent class of it. The search continues up the
parent class chain until either a suitable method is found or the parent class chain is exhausted. If a suitable
method is found, the method is executed. Otherwise, an error message is issued.
o Object
o Class
o Inheritance
o Polymorphism
o Abstraction
Any entity that has state and behavior is known as an object. For example, a chair, pen, table, keyboard, bike,
etc. It can be physical or logical.
An Object can be defined as an instance of a class. An object contains an address and takes up some space in
memory. Objects can communicate without knowing the details of each other's data or code. The only
necessary thing is the type of message accepted and the type of response returned by the objects.
Example: A dog is an object because it has states like color, name, breed, etc. as well as behaviors like
wagging the tail, barking, eating, etc.
14. Class
Collection of objects is called class. It is a logical entity.
A class can also be defined as a blueprint from which you can create an individual object. Class doesn't
consume any space.
Inheritance
When one object acquires all the properties and behaviors of a parent object, it is known as inheritance. It
provides code reusability. It is used to achieve runtime polymorphism.
Polymorphism
If one task is performed in different ways, it is known as polymorphism. For example: to convince the
customer differently, to draw something, for example, shape, triangle, rectangle, etc.
Another example can be to speak something; for example, a cat speaks meow, dog barks woof, etc.
Abstraction
Hiding internal details and showing functionality is known as abstraction. For example phone call, we don't
know the internal processing.
Encapsulation
Binding (or wrapping) code and data together into a single unit are known as encapsulation. For example, a
capsule, it is wrapped with different medicines.
A java class is the example of encapsulation. Java bean is the fully encapsulated class because all the data
members are private here.
Coupling
Coupling refers to the knowledge or information or dependency of another class. It arises when classes are
aware of each other. If a class has the details information of another class, there is strong coupling. In Java,
we use private, protected, and public modifiers to display the visibility level of a class, method, and field. You
can use interfaces for the weaker coupling because there is no concrete implementation.
Cohesion
Cohesion refers to the level of a component which performs a single well-defined task. A single well-defined
task is done by a highly cohesive method. The weakly cohesive method will split the task into separate parts.
The java.io package is a highly cohesive package because it has I/O related classes and interface. However,
the java.util package is a weakly cohesive package because it has unrelated classes and interfaces.
Association
Association represents the relationship between the objects. Here, one object can be associated with one
object or many objects. There can be four types of association between the objects:
o One to One
o One to Many
o Many to One, and
Let's understand the relationship with real-time examples. For example, One country can have one prime
minister (one to one), and a prime minister can have many ministers (one to many). Also, many MP's can
have one prime minister (many to one), and many ministers can have many departments (many to many).
Aggregation
Aggregation is a way to achieve Association. Aggregation represents the relationship where one object
contains other objects as a part of its state. It represents the weak relationship between objects. It is also
termed as a has-a relationship in Java. Like, inheritance represents the is-a relationship. It is another way to
reuse objects.
Composition
The composition is also a way to achieve Association. The composition represents the relationship where one
object contains other objects as a part of its state. There is a strong relationship between the containing
object and the dependent object. It is the state where containing objects do not have an independent
existence. If you delete the parent object, all the child objects will be deleted automatically.
Buzzwords of Java
The inventors of Java wanted to design a language which could offer solutions to some of the problems en-
countered in modern programming. They wanted the language to be not only reliable, portable and distrib-
uted but also simple, compact and interactive. The authors of Java have written an influential White Paper
Simple
Object Oriented
Platform Independent
Distributed
Robust
Secure
Architecture Neutral
Portable
Interpreted
High Performance
Dynamic
1. Simple
Java is an object-oriented programming language with syntax and keywords almost identical to C++. When
developing Java, its creators took all of the good features of the existing object-oriented programming lan-
guages such as C++, Ada, and Smalltalk, and removed most of their flaws and peculiarities. There are a lot of
aspects of the Java language that are consistent and make sense, thereby making it easier to learn.
If you are familiar with C++ you would know about clumsy features of C++: header files, pointer arithmetic (or
even pointer syntax), structures, unions, operator overloading, virtual base classes, and so on. All these
Any programming language if supports Encapsulation, Abstraction, Inheritance, Polymorphism then that lan-
If you have just started learning java, definitely it is very hard to understand the Object oriented program-
ming (OOP) concepts. Once you learn java completely then you will understand these concepts. Many java
professional who are using these concepts in their daily life will fail to define OOP (Object Oriented Program-
ing) concepts. Below are the definitions of OOP concepts which will surely help you when you are attending
Encapsulation: It is the Process of binding the data and methods together into a single unit. Example: Binding
Abstraction: Showing Essential properties and methods of an object by hiding internal things is called as Ab-
straction. Abstraction is possible if and only if there is encapsulation. Example: Java is an abstraction layer
Inheritance: Inheriting the properties and methods of one class (super class) into another class (sub class) us-
ing IS a relationship. Example: Ferrari class inherits the features of Car class. Puppy class inherit the features
ual platform/OS. Program written in Windows platform can run in Linux platform. Output of java compiler
(javac.exe in windows) is a bytecode (.calss file), but not native machine code. This bytecode is interpreted by
virtual machine (not by real computer) as real computer interprets .exe files in C/C++. Such a virtual machine
Translating java program into Byte code makes it much easier to run a program in wide variety of platforms/
Environments, because only JVM need to be implemented. Once bytecode is ready, we can run it in windows,
Linux, calculator, mobile, watch etc.., but one thing is all environments require just JVM. Details of JVM differ
4. Distributed
A technology is said to be distributed if it's business objects are geographically dispersed into
An elegant mechanism, called servlets, makes server-side processing in Java extremely effi-
5. Robust
Programming language is robust when it is reliable and strong. Below capabilities make java robust:
In java you do not use pointers to access strings, arrays, objects, even files. Nor do you need to
Java has exception handling mechanism which is very useful in handling both compile and run
time errors. Without handling errors and exceptions, entire application would fail. With exception
handling it just stops the current flows even that are when failed, but rest all flows still runs.
6. Secure
Java team has said that they will have a “zero tolerance” for security bugs and will immediately go to work on
fixing any bugs found. Java program will be first compiled to byte code. This byte code will then be inter-
preted by Java Virtual Machine (JVM). JVM makes java secure with below factors:
JVM will not corrupt memory outside its own process space.
JVM will not read or write to local files when invoked through a security-conscious class
loader.
7. Architecture Neutral
The compiler generates architecture-neutral bytecode instructions which have nothing to do with particular
computer architecture. These bytecode instructions can be run by only JVM. JVM is not same for platforms
and architectures. Java will provide you different JVMs for different platforms and architectures. So you just
have to install different JVMs. A bytecode once ready can be run by any JVM.
A program written in 32 bit operating system can be run by JVM in 64 bit operating system.
8. Portable
In C/C++ data size varies from platform to platform. For example integer can be a 16-bit integer, a 32-bit inte-
ger, or any other size that the compiler vendor likes. In java has a fixed size for data that eliminates a major
porting headache. Binary data is stored and transmitted in a fixed format, eliminating the “big endian/little
endian” confusion. Strings are saved in a standard Unicode format. Java does this by JVM. Java facilitates you
to carry the Java bytecode to any platform. It doesn't require write different program for different platforms
machine to which the interpreter has been ported. Since installing JVM is a lightweight process, the develop-
interpreter, it seemed that Java bytecode programs could never run as quickly as programs compiled into na-
tive machine language (that is, the actual machine language of the computer on which the program is run-
ning). However, this problem has been largely overcome by the use of just-in-time compilers (JIT) for execut-
this while it is executing the program. Just as for a normal interpreter, the input to a just-in-time compiler is a
It is important to understand that it is not practical to compile an entire Java program into executable code all
at once, because Java performs various run-time checks that can be done only at run time. Instead, a JIT com-
piler compiles code as it is needed, during execution. Furthermore, not all sequences of bytecode are com-
piled—only those that will benefit from compilation. The remaining code is simply interpreted. The translated
parts of the program can then be executed much more quickly than they could be interpreted. Since a given
part of a program is often executed many times as the program runs, a just-in-time compiler can significantly
11. Multithreaded
A thread is defined as a separate path of execution inside any process. It is done to use CPU idle time. A
process consists of the memory space allocated by the operating system that can contain one or more
threads. A thread cannot exist on its own; it must be a part of a process. Whenever a thread is created within
a program it will not occupy any separate space. It will share the same memory space of the program. It will
pendent in this regard. Only the code for calling multithreading remains the same across machines; Java off-
loads the implementation of multithreading to the underlying operating system or a thread library.
12. Dynamic
In a number of ways, Java is a more dynamic language than C or C++. It was designed to adapt to an evolving
environment. Libraries can freely add new methods and instance variables without any effect on their clients.
In Java, finding out run time type information is straightforward. This is an important feature in those situa-
Overview of java:
Java is a widely-used, object-oriented programming language that was developed by Sun Microsystems (now
owned by Oracle Corporation) and released in 1995. It was designed to be platform-independent, allowing
developers to write code that can run on any system with a Java Virtual Machine (JVM) installed. Here's an
overview of Java:
1. Simple and Familiar Syntax: Java's syntax is derived from the C and C++ programming languages,
making it relatively easy for developers familiar with those languages to learn Java. It has a clean and struc-
tured syntax, with a strong emphasis on readability and maintainability.
2. Platform-Independence: One of Java's key features is its "Write Once, Run Anywhere" principle. Java
source code is compiled into bytecode, which can be executed on any system with a compatible JVM. This al-
lows Java applications to run on diverse platforms, including Windows, macOS, Linux, and more.
3. Object-Oriented Programming (OOP): Java is designed around the principles of object-oriented pro-
gramming. It supports concepts such as classes, objects, inheritance, polymorphism, and encapsulation. This
makes it suitable for building modular and extensible applications.
4. Robust and Safe: Java places a strong emphasis on reliability and security. It includes features like au-
tomatic memory management (garbage collection) to handle memory allocation and deallocation, exception
handling to manage errors, and strong type-checking to catch potential programming mistakes at compile-
time.
5. Rich Standard Library: Java comes with a comprehensive standard library that provides a wide range
of pre-built classes and APIs. This library covers areas such as input/output operations, networking, database
connectivity, graphical user interface (GUI) development, multithreading, and more. The standard library sim-
plifies development and reduces the need for developers to reinvent the wheel.
6. Large Ecosystem: Java has a vast and active ecosystem with a multitude of open-source libraries,
frameworks, and tools. These resources enhance productivity, enable rapid development, and offer solutions
for various domains such as web development (e.g., Spring Framework), enterprise software (e.g., Java EE),
data processing (e.g., Apache Hadoop), and more.
7. Support for Concurrency: Java provides built-in support for concurrent programming. It includes fea-
tures like threads, synchronization, and thread pools, allowing developers to write code that efficiently han-
dles multiple tasks simultaneously. This is especially useful for applications that require parallel processing or
responsiveness.
8. Popular in Enterprise Development: Java has long been a popular choice for enterprise software de-
velopment. Its robustness, scalability, and extensive ecosystem make it well-suited for building large-scale,
COURSE OUTCOMES:
Course Bloom’s Tax-
Course Outcome Statement
Outcome onomy level
CO1 Understand
Understanding the real world problem solving concepts using
OOP techniques.
CO2 Understand and able to solve the various class based problem Understand & Apply
solving techniques.
CO3 Understand and able to indentifying the problems based on Analyze & Apply
java collection framework and I/O Classes .
CO4 Understand and identify the problems & able to solve the Understand & apply
multithreading applications and synchronization using java
collection framework and I/O Classes .
CO5 Understanding and applying knowledge over GUI pro- Understand & Ana-
gramming with Swing, Event Handling &applet appli- lyze
cation
PO PO PO PO PO PO PO PO PO PO PO PO PS PS
1 2 3 4 5 6 7 8 9 10 11 12 O1 O2
CO1 3 - - - - - - - - - - - - 1
CO2 3 - - - - - - - - - - - - 2
CO3 3 3 3 2 - - - - - - - - - 1
CO4 3 3 2 3 - - - - - - - - - 2
CO5 3 3 3 3 - - - - - - - - - 1