0% found this document useful (0 votes)
9 views5 pages

Helen

Uploaded by

25Udhavi verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

Helen

Uploaded by

25Udhavi verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

HELEN:

Abstract class interface


constructor
stream ApI
springBoot
HTML CSS JAVASCRIPT
XML
how springBoot connected with database
Stringbuilder
stringbuffer
stream.reduce()
how to start springboot application
@Springbootapplication
Agetpost put patch delete mapping
rest API
@request param
implement lambda expression ihn stream api
________________________________________________________________________________
ABSTRACT CLASS AND INTERFACE:
Definition: An abstract class is a class that cannot be instantiated and can
contain both abstract and non-abstract methods12. An interface, on the other hand,
is a contract that specifies a set of methods that a class must implement.
Methods: An abstract class can have both abstract and non-abstract methods. Since
Java 8, interfaces can have default and static methods in addition to abstract
methods.
Inheritance: An abstract class can extend another Java class and implement multiple
Java interfaces. An interface can extend another Java interface only. A class can
inherit from only one abstract class, but it can implement multiple interfaces.
Variables: An abstract class can have final, non-final, static, and non-static
variables1. The interface has only static and final variables.
Access Modifiers: An abstract class can have class members like private, protected,
etc1. Members of a Java interface are public by default1.
Implementation: An abstract class can provide the implementation of an interface1.
An interface can’t provide the implementation of an abstract class1.
Keywords: The abstract keyword is used to declare an abstract class1. The interface
keyword is used to declare an interface

a real-life example of a Car to understand Interface and Abstract Class.

Interface: An interface is like a contract or protocol. It defines what actions an


object can take, but it doesn’t specify how those actions are implemented.

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();
}

Abstract Class: An abstract class is a class that can’t be instantiated and is


typically used as a base class for other classes. Abstract classes can contain both
abstract methods (methods without a body) and concrete methods (methods with a
body).
For example, consider an abstract class Car. This class might have an abstract
method calculateFuelEfficiency() and a concrete method turnOnRadio().

Java

abstract class Car {


abstract void calculateFuelEfficiency();

void turnOnRadio() {
System.out.println("Radio is on");
}
}

_________________________________________________________________________________
CONSTRUCTOR:

A constructor in object-oriented programming is a special method used to initialize


a newly created object. It’s called when an instance of the class is created.
Remember, the constructor has the same name as the class and it doesn’t have a
return type.
A constructor is a special method in a class that is automatically called when an
object of that class is created
THERE ARE DIFFERNT TYPE OF CONSTRUCTORS ATER THERE:
Default Constructor: If you don’t define a constructor in your class, the compiler
automatically provides a default constructor. This constructor doesn’t take any
parameters and doesn’t do anything
Parameterized Constructor: A constructor that takes parameters is known as a
parameterized constructor. You can use this to initialize your object with specific
values at the time of creation.
Copy Constructor: A copy constructor is a parameterized constructor that takes an
object of the same class as a parameter, and it’s used to copy the values of one
object into another.

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.
___________________________________________________________________________________
___-

XML, or Extensible Markup Language, is a markup language that defines a set of


rules for encoding documents in a format that is both human-readable and machine-
readable12. It’s a software- and hardware-independent tool for storing and
transporting data
_________________________________________________________________________________-
API
An API, or Application Programming Interface, is a set of rules or protocols that
allows software applications to communicate with each other.
Communication Between Software: APIs enable different software components to
communicate and transfer data.
Data Exchange: APIs are used to exchange data between different software
applications12345.
Protocols and Rules: APIs consist of a set of protocols and rules that dictate how
software components should interact12345.
Use in Web Development: APIs are often used in web development to allow web
applications to communicate with each other

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

REST API-A REST (Representational State Transfer) API (Application Programming


Interface) is a set of rules and conventions for building and interacting with web
services. It’s a way for different software systems to communicate with each other
over HTTP, similar to how web servers respond to browser requests.

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);

// Using a Stream to filter even numbers and then double them


List<Integer> evenNumbers = numbers.stream()
.filter(n -> n % 2 == 0)
.map(n -> n * 2)
.toList();

System.out.println("Doubled Even Numbers: " + evenNumbers);


}}
FEATURE:A stream is not a data structure instead it takes input from the
Collections, Arrays or I/O channels.
Streams don’t change the original data structure, they only provide the result as
per the pipelined methods.
Each intermediate operation is lazily executed and returns a stream as a result,
hence various intermediate operations can be pipelined.
two types of Operations in Streams:
#Intermediate Operations-(Methods are chained together.
Intermediate operations transform a stream into another stream.)
1. map()
The map method is used to return a stream consisting of the results of applying the
given function to the elements of this stream.

List number = Arrays.asList(2,3,4,5);


List square = number.stream()
.map(x->x*x)
.collect(Collectors.toList());
2. filter()
The filter method is used to select elements as per the Predicate passed as an
argument.

List names = Arrays.asList("Reflection","Collection","Stream");


List result = names.stream()
.filter(s->s.startsWith("S"))
.collect(Collectors.toList());
3. sorted()
The sorted method is used to sort the stream.

List names = Arrays.asList("Reflection","Collection","Stream");


List result = names.stream()
.sorted()
.collect(Collectors.toList());

#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.

List number = Arrays.asList(2,3,4,5,3);


Set square = number.stream()
.map(x->x*x)
.collect(Collectors.toSet());
2. forEach()
The forEach method is used to iterate through every element of the stream.

List<String> names = Arrays.asList("Alice", "Bob", "Charlie");


names.stream()
.forEach(name ->
System.out.println("Hello, " + name));

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.

List number = Arrays.asList(2,3,4,5);


int even = number.stream()
.filter(x->x%2==0)
.reduce(0,(ans,i)-> ans+i); or.reduce(0, (total, num) -> total + num)
________________________________________________________________________
SPRINGBOOT-
Spring Boot is built on the top of the spring and contains all the features of
spring. And is becoming a favorite of developers these days because of its rapid
production-ready environment which enables the developers to directly focus on the
logic instead of struggling with the configuration and setup. Spring Boot is a
microservice-based framework and making a production-ready application in it takes
very little time. Following are some of the features of Spring Boot:
It allows avoiding heavy configuration of XML which is present in spring
It provides easy maintenance and creation of REST endpoints
It includes embedded Tomcat-server
Deployment is very easy, war and jar files can be easily deployed in the tomcat
server.
___________________________________________________________________________________
______________________
STRING ,STRING BUFFER ,STRING BUILDER
Java provides three classes to represent a sequence of characters: String,
StringBuffer, and StringBuilder. The String class is an immutable class whereas
StringBuffer and StringBuilder classes are mutable
BUFFER-StringBuffer is synchronized i.e. thread safe. It means two threads can't
call the methods of StringBuffer simultaneously.StringBuffer is less efficient than
StringBuilder.
BUILDER-StringBuilder is non-synchronized i.e. not thread safe. It means two
threads can call the methods of StringBuilder simultaneously.

You might also like