Unit-1 and Unit-2
Unit-1 and Unit-2
Every Java application has a class definition, and the name of the class should match the filename in Java.
Every application in Java must contain the main method. The Java compiler starts executing the code from the
main method.
What is JRE?
JRE (Java Runtime Environment) is a software package that provides Java class libraries, Java Virtual Machine
(JVM), and other components that are required to run Java applications.
JRE is the superset of JVM.
What is JDK?
JDK (Java Development Kit) is a software development kit required to develop applications in Java. When you
download JDK, JRE is also downloaded with it.
In addition to JRE, JDK also contains a number of development tools (compilers, JavaDoc, Java Debugger,
etc).
Method overloading
In Java, two or more methods may have the same name if they differ in parameters (different number of
parameters, different types of parameters, or both). These methods are called overloaded methods and this
feature is called method overloading. For example:
What is a Constructor?
A constructor in Java is similar to a method that is invoked when an object of the class is created.
Unlike Java methods, a constructor has the same name as that of the class and does not have any return type.
For example,
Types of Constructor
In Java, constructors can be divided into 3 types:
1. No-Arg Constructor No-Arg Constructor
2. Parameterized Constructor
3. Default Constructor
No-Arg Constructor
If a constructor does not accept any parameters, it is known as a no-argument constructor.
Parameterized Constructor
A Java constructor can also accept one or more parameters. Such constructors are known as parameterized
constructors (constructor with parameters).
Java Default Constructor
If we do not create any constructor, the Java compiler automatically create a no-arg constructor during the
execution of the program. This constructor is called default constructor.
Constructors Overloading in Java
Similar to Java method overloading, we can also create two or more constructors with different parameters.
This is called constructors overloading.
In Java, it is not allowed to declare two or more variables having the same name inside a scope (class scope or
method scope). However, instance variables and parameters may have the same name. For example,
In the above example, we have passed 8 as a value to the constructor. However, we are getting 0 as an output.
This is because the Java compiler gets confused because of the ambiguity in names between instance the
variable and the parameter.
Notice the use of the @Override annotation in our example. In Java, annotations are the metadata that we used
to provide information to the compiler. Here, the @Override annotation specifies the compiler that the method
after this annotation overrides the method of the superclass.
It is not mandatory to use @Override. However, when we use this, the method should follow all the rules of
overriding. Otherwise, the compiler will generate an error.
Super Keyword
2.To access attributes (fields) of the superclass if both superclass and subclass have attributes with the same
name.
3.To explicitly call superclass no-arg (default) or parameterized constructor from the subclass constructor.
An abstract class can have both the regular methods and abstract methods.
If a class contains an abstract method, then the class should be declared abstract. Otherwise, it will generate an
error.
Though abstract classes cannot be instantiated, we can create subclasses from it. We can then access members
of the abstract class using the object of the subclass. For example,
The major use of abstract classes and methods is to achieve abstraction in Java.
Java Interface
An interface is a fully abstract class. It includes a group of abstract methods (methods without a
body).
We use the interface keyword to create an interface in Java. For example,
Like abstract classes, we cannot create objects of interfaces.
To use an interface, other classes must implement it. We use the implements keyword to implement
an interface.
2. Plan
“What do we want?” In this stage of the SDLC, the team determines the cost and resources required for
implementing the analyzed requirements. It also details the risks involved and provides sub-plans for softening
those risks.
In other words, the team should determine the feasibility of the project and how they can implement the project
successfully with the lowest risk in mind.
3. Design
“How will we get what we want?” This phase of the SDLC starts by turning the software specifications into a
design plan called the Design Specification. All stakeholders then review this plan and offer feedback and
suggestions. It’s crucial to have a plan for collecting and incorporating stakeholder input into this document.
Failure at this stage will almost certainly result in cost overruns at best and the total collapse of the project at
worst.
4. Build
“Let’s create what we want.”
At this stage, the actual development starts. It’s important that every developer sticks to the agreed blueprint.
Also, make sure you have proper guidelines in place about the code style and practices.
For example, define a nomenclature for files or define a variable naming style such as camelCase. This will
help your team to produce organized and consistent code that is easier to understand but also to test during the
next phase.
5. Code Test
“Did we get what we want?” In this stage, we test for defects and deficiencies. We fix those issues until the
product meets the original specifications.
In short, we want to verify if the code meets the defined requirements.
6. Software Deployment
“Let’s start using what we got.”
At this stage, the goal is to deploy the software to the production environment so users can start using the
product. However, many organizations choose to move the product through different deployment environments
such as a testing or staging environment.
This allows any stakeholders to safely play with the product before releasing it to the market. Besides, this
allows any final mistakes to be caught before releasing the product.
The most common SDLC examples or SDLC models are listed below.
◼ Waterfall Model
◼ Agile Model
◼ Iterative Model
◼ Iterative Model
◼ Spiral Model
Types of DBMS
In general, there are two common types of databases:
⚫ Non-Relational
⚫ Relational
Non-Relational Database Management System (Non-RDBMS)
In Non-RDBMS, data is stored in key-value pairs. For example:
The first row is the attributes of the table. Each row after that contains the data of a customer.
In RDBMS, two or more tables may be related to each other. Hence the term "Relational". For example,
Here, orders and customers are related through customer_id.
Commonly used RDBMS: MySQL, PostgreSQL, MSSQL, Oracle etc.
Note: To access data from these relational databases, SQL (Structured Query Language) is used.