Helen
Helen
For example, consider a CarInterface. This interface might declare methods like
startEngine(), accelerate(), and brake(). Any class that implements this interface
must provide the implementation for these methods.
Java
interface CarInterface {
void startEngine();
void accelerate();
void brake();
}
Java
void turnOnRadio() {
System.out.println("Radio is on");
}
}
_________________________________________________________________________________
CONSTRUCTOR:
THIS. :this is a keyword that refers to the current instance of the class. It’s
used to access the fields, methods, or constructors of the current object
GIVE EXAMPLE FROM YOUR PROJECT TAKE CUSTOMER ENTITY CLASS IN THAT I HAVE CREATED
OBJECTS REPRESENTING REAL WORLD ,CUSTOMERS LIKE USER-NAME, EMAIL IS CALL
CONSTRUCTOR TO INITIALISE ALL MY OBJECTS.
___________________________________________________________________________________
________
HTML (HyperText Markup Language): HTML is used for structuring web content. It
provides the basic structure of sites, which is enhanced and modified by other
technologies like CSS and JavaScript1. HTML uses “markup” to annotate text, images,
and other content for display in a Web browser2. HTML markup includes special
“elements” such as <head>, <title>, <body>, <header>, <footer>, <article>,
<section>, <p>, <div>, <span>, <img>, <aside>, <audio>, <canvas>, <datalist>,
<details>, <embed>, <nav>, <output>, <progress>, <video>, <ul>, <ol>, <li> and many
others2.
CSS (Cascading Style Sheets): CSS is used for styling and layout of web pages1. CSS
is used to style and lay out web pages — for example, to alter the font, color,
size, and spacing of your content, split it into multiple columns, or add
animations and other decorative features2. You can think of CSS as the makeup of
the web. It’s used to add colors, backgrounds, layouts, font sizes, and more. This
technology is what makes websites look attractive3.
JavaScript: JavaScript adds interactivity and functionality to web pages1.
JavaScript is a scripting language that enables you to create dynamically updating
content, control multimedia, animate images, and pretty much everything else2.
JavaScript makes HTML pages more dynamic and interactive2. For example, JavaScript
can change content, styles, and attributes dynamically2.
Together, these three technologies form the cornerstone of web development. They
each serve a distinct purpose and work together to create a seamless user
experience. HTML provides the structure, CSS adds the styling, and JavaScript
brings it all to life with interactivity3.
___________________________________________________________________________________
___-
Here’s a simple real-life example of an API: When you use an app on your phone, the
app sends a request to the server via an API (that’s the waiter in this analogy).
This request might be to retrieve data (like asking the waiter for the menu), to
send data (like placing your order), or to delete data (like asking for the bill).
The server then responds via the API (the waiter brings back your order) with the
requested data, which the app then presents to you
In our Weather Forecasting Application, let’s say we have a mobile app that needs
to display the weather forecast to the user. The app doesn’t have this data on its
own, so it needs to request it from a server that has access to weather data.
GET Request: The mobile app makes a GET request to the server’s REST API. The
request might look something like this: GET http://api.weather.com/forecast?
city=NewYork. This request is asking for the weather forecast for New York.
Server Processing: The server receives the request, processes it, fetches the
required data (in this case, the weather forecast for New York), and prepares the
data to be sent back to the client.
Response: The server sends a response back to the client. The response contains the
requested data in a structured format, usually JSON or XML. The data might look
something like this:
Client Processing: The mobile app receives the response from the server, parses the
data, and displays the weather forecast to the user.
REST API allows the mobile app to interact with the server to retrieve weather
data. The app doesn’t need to know how the server fetches or stores this data; it
only needs to know what requests to make to the API.
This is a simplified example, but it gives you an idea of how REST APIs work in
real-world applications.
API (Application Programming Interface): It’s like a menu in a restaurant. The menu
provides a list of dishes you can order, along with a description of each dish.
When you specify what menu items you want, the restaurant’s kitchen does the work
and provides you with some finished dishes. You don’t know exactly how the
restaurant prepares that food, and you don’t really need to.
REST API (Representational State Transfer API): This is a set of rules that
developers follow when they create their API. It’s like having a specific way to
order the dishes from the menu. For example, one rule might be that you need to
order by course, and another might be that you should specify food allergies.
So, an API is a general set of rules for how an application communicates with
another. A REST API is a specific set of rules that follows the principles of REST
___________________________________________________________________________________
___________-
Stream API is used to process collections of objects. A stream in Java is a
sequence of objects that supports various methods which can be pipelined to produce
the desired result.
Syntax
Stream<T> stream; T is either a class, object, or data type depending upon the
declaration.
public class Main {
public static void main(String[] args) {
List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
#Terminate Operations-(Operations that return the result. These Operations are not
processed further just return a final result value.)
collect()
The collect method is used to return the result of the intermediate operations
performed on the stream.
The reduce method is used to reduce the elements of a stream to a single value. The
reduce method takes a BinaryOperator as a parameter.