3. Scenario based Question
- Imagine a situation where we need to collect the names of 50 students
- How will you write a Java program to do this?
- Yes! You will introduce 50 new variables and collect the data
But is that way an efficient one?
8. Which mapping of 2D Arrays is right?
0,0 0,1 0,2
1,0 1,1 1,2
2,0 2,1 2,2
Row 0 Row 1
col 0 col 1 col 0 col 1
9. • Do we have any other type of Array?
• Yes! It is Jagged Array
10. • Arrays of Arrays
• Column number is different in each and every rows
Jagged Array
11. • Fetch date from client machine and store in server
• Ex: In gmail, we have the last logged in activity in our Activity log
Date and time
12. • Consider we are attending an Online exam
• Is there any possibilities to cheat during the exam?
• Yes! By changing the time in the client machine.
• Ex: Hotstar
Realtime example
13. • Association is the OOPS concept to define the relationship
between objects.
• It can be
- one –to-one
- one-to-many
- many-to-one
- many-to-many
Association
14. • It provide the relationship between two classes.
• Has-A relationship.
• contains the reference of another class and gives ownership to that class.
Aggregation
15. class Subject
{
private String name;
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
}
public class Student {
private Subject[] studyAreas = new Subject[10];
//the rest of the Student class
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
16. Interface
• collection of abstract methods.
• to overcome multiple inheritance.
• achieve loose coupling.
17.
18. Packages
• mechanism to encapsulate a group of classes, sub packages and
interfaces
• A default member (without any access specifier) is accessible by
classes in the same package only.
Title + Bullets + Image
No more than 4 points. Please use another similar slide incase you have more points.
Title + Bullets + Image
No more than 4 points. Please use another similar slide incase you have more points.
Title + Bullets + Image
No more than 4 points. Please use another similar slide incase you have more points.
Title + Bullets + Image
No more than 4 points. Please use another similar slide incase you have more points.
Title + Bullets + Image
No more than 4 points. Please use another similar slide incase you have more points.
Title + Bullets + Image
No more than 4 points. Please use another similar slide incase you have more points.
Title + Bullets + Image
No more than 4 points. Please use another similar slide incase you have more points.
In hotstar for non premium users there is a time limit to watch live cricket.
But before years we had a bug, if we change the time in our system we can use it for years, like when we get logged into the Hotstar id
It gets recorded with the exact time in our system so it will end after 30 mins. Ex: if we start by 10am on nov 1, it will end by 10:30am on the same day. Now assume we are changing the date as nov1 to the previous year where it cannot be ended.
This is how we cheat the server.
Association :
Is used to describe the relationship between two separate classes of object . The relationship can be one-to-one, one-to-many, many-to-one, many-to-many. In OOPS, the object communicates to other object by is functionality and the service provided by the object. The communication can be achieved through Aggregation and Composition.
one –to –one : A person can have only one passport.
one-to-many: A Bank can have multiple Account holders.
many-to-one: multiple cities have only one state.
many-to-many: a teacher can have multiple students, in student perspective a student can have multiple teacher.
Aggregation :
It provide the relationship between two classes. Where one class “has-a” ownership of other class.
If Class A contains a reference to Class B and Class B contains a reference to Class A then no clear ownership can be determined and the relationship is simply one of association.
if you imagine that a Student class that stores information about individual students at a school. Now assume a Subject class that holds the details about a particular subject (e.g., history, geography). If the Student class is defined to contain a Subject object then it can be said that the Student object has-a Subject object. The Subject object also makes up part-of the Student object — after all, there is no student without a subject to study. The Student object, therefore, owns the Subject object.
Interface:
It achieve Abstract Method, it support the functionality of multiple inheritance. We can have Multiple interfaces. Where [class extends interface] and [interface also extends interface] but[ class should implement the interface]. Is used to hide the implementation details which runs in background.
Exception:
Is used to handle runtime error,which occurs during normal flow of exceution
if an exception occurs, which has not been handled by programmer then program execution gets terminated and a system generated error message is shown to the user. For example look at the system generated.
Errors indicate that something severe enough has gone wrong, the application should crash rather than try to handle the error.
Exceptions are events that occurs in the code. A programmer can handle such conditions and take necessary corrective actions.