- Write Fibonacci series programming and explain logic
- how auto wiring works in spring
- write a program for dependency injection
- how security is implemented in your project.
- difference between filter and map in java streams.
- Explain about your current project.
- How to read the file and display total count of each word.
- How angular Makes calls to spring boot
- What is spring profile
- There is a list with emp objects with duplicate name, age attributes. How to retrieve uniques names.
- What Technologies used in last project.
- Abstract class and encapsulation.
- What is HashMap? how it works.
- what is inter thread communication
- what ArrayList ? extends object and ArrayList? super object means
- what is splice and slice
- difference between == and ===
- Write a Java 8 program to get the sum of all numbers present in a list?
- what FlatMap?
- write a prog ..how to sort emp obj in java8
- Given the list of employees, find the employee with name “R”.
- Angular Routing process
- Difference Between constructor vs ngOnInit in Angular
- how to find which datatype is created in JavaScript
- what is id in CSS
- how to create a singleton object
- what is static method, static block and static class
- what will happen if we add final to a method
- what is @path and path param, path variable
- what is multi catch block
- what is subquery and when we use it
- how to use service in angular
- difference between @Input and @Output in angular
- what is event emitter
- what is @beanpropertyrowmapper
- Handle cross horizon resource sharing-angular, how can u candle hash code, equal
- sql query, highest salary- department wise
- Routing in Angular
- import and export in ngModule
- what is ngModule
- directives and use of them in angular
- routes in angular
- what is children attribute in routes in angular
- Hibernate OneToMany and ManyToOneMapping example
- How to return a single user if userId passed or list of users if userId not passed in JPA
- Micro services communication
- Autorization and authentication process in current project
- String reverse program
- Spring JPA Example
- Factory design pattern
- Singleton Design pattern and real time usage and implementation
- How to prevent singleton object from clone?
- Synchronous and asynchronous requests, how to consume angular http request and services
- Springcloud config
- publishing a service in spring cloud
- diff b\w rest and soap
- what is the new in the current java version compared with previous versions?
- What is the lambda expression?
- What is a functional interface and it’s example?
- How many ways to create a thread and it’s life cycle?
- What are streams in java?
- What is the difference between a hashset and concurrenthashset?
- Difference between hashmap and concurrenthashmap
- What is LinkedHashMap
- What is a static method in java?
- How the static class locking works?
- what is a singleton design pattern and how do you create it?
- What are directives in angular?
- What are pipes in angular?
- How do components communicate with each other and data transfer among them?
- What is DDL and DML??
- What is the difference between Truncate and Delete?
- What is the difference between function and procedure?
- What is immutable class
- Method to find missing number in a Array list with value from 0-100. (number 7 and are missing)
- find the number of integer appear in a array list having duplicates
- Explain Quick sort
- Serialization
- what is executer framework and cachethreadpool
- How hashMap works internally
- Spring & Microservice
- What is microservice and its architecture
- How to handle situation if one of microservice fails
- What is API gateway
- What is client side load balancing
- Spring life cycle
- What is dependency Injection
- Annotation used in circuit breaker implementation
- Microservice design patterns
- fast iterate and safe iterate
- How you read file from angular
- difference between get and load in hibernate
- Spring JPA CRUD Repository
- jdbcTemplate methods
- difference between Observer and subscribe in angular
- Spring boot and hibernate integration steps
- How you read properties file from springboot
- sql query for one to many mapping.
- Functional interface.
- Design patterns used Realtime in your application.
- Java Multithreading – wait & notify, Obtaining lock.
- Static and Dynamic Overloading.
- Spring security its annotations.
- Java 1.8 features.
- Angular Observable subscribe and unsubscribe.
- what happens when we call a void method in a system.out.println()?
- What is Resource(Request) and Response in Restful services?
- how can I return custom data instead of JSON or XML content for a Rest response?
- what are stream(s) in java and few operations on them like comparison
- difference between comparable and comparator
- why Clonable is not implemented by Collection interface, reason?
- Components in angular
- What is the life cycle of components in angular
- Sharing data between components in Angular
- Type Script compilation process
- Angular life cycle
- what are gate in angular
- in how many ways I can sort my employee object with the given set of columns, explain?
- How to create schedulers in java
- How we implement batch import and export functionality in spring.
- How to maintain session in server side.
- Lifecycle process of angular
- How to reload header and footer menu based on particular left menu routing
- Box model in CSS
- Pseudo selector in CSS
- Difference between display block & display inline-block
- Difference between position absolute and position relative
- What is the internal implementation of HashMap?
- What is the algorithm/datastructure used to get an emlement from HashMap?
- How to make HashMap synchronized
- Difference between HashMap & concurrent hash map
- Authenticate client side in angular
- Time difference calculation in angular
- How to create Generic class in angular
- Difference between Post and PUT
- Stored Procedures
- Monolithic architecture and Microservice Architecture
- java 8 new features
- List of collections used
- How exceptions are handled
- Throw and Throws
- Final, Finally, Finalize
- Spring IOC
- Spring boot advantages
- JPA repository
- First level second level cache in hibernate
- Union vs Union all
- Spring security
- Spring transactions
- Custom directives
- Get and post in angular
- employee has id, name, salary. Find the list of employees where the employee name starts with “n” using java8?
- can you the same in ArrayList and array?
- Vulnerability checking process in the front end
- Have you worked on Cross Site Scripting?
- What are the challenged faced in Cross Site Scripting?
- Have you worked in Custom annotation creation in Java?
- if yes? Could you explain the implementation of custom annotation?
- Where thread class variables will get store in Memory?
- What are the different databases you worked?
- Did you face any query performance issues? how did you increase the performance of the query?
- What is index and query of it?
- What is the data structure used to create an index?
- How can you handle the errors in Spring Boot?
- Can you explain what are the dependencies required to create REST application in Spring Boot? what other classes needs to be created to perform CURD operations and it’s flow?
- How you worked on application security?
- angular life cycle hooks
- Explain insertion sort logic
- Write query to get 3rd highest salary of employee
- How to get the average value of integers using streams
- What are method references
- What are for lambda expressions introduced and what is the advantage
- explain proxy pattern
- how to find duplicate user object user {name, age}
- What is observable
- What is cluster index
- What is the deployment procedure of Micro services
- Explain service discovery pattern
- What is containerization
- how to import module and service in Angular
- Difference between monolithic and microservices architecture.
- Difference between Spring and Spring boot
- Explain about Spring boot starter
- Spring security
- @Springboot application
- Gates in angular
- Life cycle of angular hooks
- How to pass the data between components.
- Structural and behavioral directives
- Multi threading concepts
- Architecture of the current project where you are working
- Architecture of angular application
- Difference between soap and Rest
- Questions on GIT code checkout process
- Questions on Front end security concepts
- Code deployment procedure
- Load balancing concepts related to services
- REST and SOAP justification for usage
- Questions based on resume and projects explanation Why ? What ?
- How we used if we mention any technology
Tag: java
Java : Lambda Expression
What is Lambda expression?
As per Wikipedia, lambda expression also called as anonymous function. It’s a function without name and does not belong to any class. Lambda expression is introduced as part of Java 8 features.
A traditional method or function in java has these main parts.
- Name
- Parameter list
- Body
- Return type
A lambda expression in java has these main parts.
- No Name: as this is anonymous function there is no name needed
- Parameter list
- Body: this is the main part of the function
- No return type: you don’t need to mention the return type in lambda’s expression. The java 8+ compiler is able to infer the return type by checking the code.
Program of using lambda expression without any parameters:
@FunctionalInterface
interface NoParamInterface{
String printHelloWorld();
}
public class NoParamLambdaTest{
public static void main(String[] args) {
NoParamInterface noParamInterface= () -> "Hello World";
System.out.println(noParamInterface.printHelloWorld());
}
}
Program of using Lambda expression with single parameter:
@FunctionalInterface
interface SingleParam{
int incrementBy10(int x);
}
public class SingleParamLambdaTest {
public static void main(String[] args) {
SingleParam singleParam = (x) -> x+10;
System.out.println(singleParam.incrementBy10(5));
}
}
Program of using Lambda expression with multiple parameters:
@FunctionalInterface
interface MultiParam{
String concat(String x, String y);
}
public class MultiParamLambdaTest {
public static void main(String[] args) {
MultiParam multiParam = (x, y) -> x+" "+y;
System.out.println(multiParam.concat("Hello", "World"));
}
}
Program of using Lambda expression with Runnable interface:
public class RunnableExample {
public static void main(String[] args) {
//Traditional way of implementation
Runnable runnable = new Runnable() {
@Override
public void run() {
int sum=0;
for(int i=0;i<10;i++)
sum +=i;
System.out.println("Traditional : "+sum);
}
};
new Thread(runnable).start();
//Implementing using lambda
Runnable runnable1 = () -> {
int sum=0;
for(int i=0;i<10;i++)
sum +=i;
System.out.println("Lambda : "+sum);
};
new Thread(runnable1).start();
//Implementing Thread with Lambda
new Thread(()->{
int sum=0;
for(int i=0;i<10;i++)
sum +=i;
System.out.println("Thread with Lambda : "+sum);
}).start();
}
}
Program of using Lambda expression with Callable interface:
import java.util.Arrays;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.IntStream;
public class CallableExample {
public static int[] array = IntStream.range(0,5000).toArray();
public static int count = IntStream.range(0,5000).sum();
public static void main(String[] args) throws InterruptedException, ExecutionException {
Callable<Integer> callable1 = () -> {
int sumOfEven=0;
for(int i=0;i<array.length;i++){
if(i%2 == 0)
sumOfEven = sumOfEven + i;
}
return sumOfEven;
};
Callable<Integer> callable2 = () -> {
int sumOfOdd=0;
for(int i=0;i<array.length;i++){
if(i%2 == 1)
sumOfOdd = sumOfOdd + i;
}
return sumOfOdd;
};
ExecutorService executorService = Executors.newFixedThreadPool(2);
System.out.println("Sum of Even of given range: "+executorService.invokeAny(Arrays.asList(callable1)));
System.out.println("Sum of Odd of given range: "+executorService.invokeAny(Arrays.asList(callable2)));
executorService.shutdown();
System.out.println("Count of the given range is : "+count);
System.out.println("Sum of Odd and Even is equals to count");
}
}
How InOut parameter will work in java?
Objective:
Objective of this article is to explain How references will work in java or How InOut parameter will work in Java?
Explanation:
We studied in C language the importance of pointers similarly we need to know how references are working in java. Without knowing how object references are working in java, we cant understand application flow properly.
Lets take one example in java related to references as well as InOut parameter in java.
class Student{
private Integer id;
private String name;
//setter and getter
}
class Main{
public static void main(String arg…){
Student s1=new Student();
System.out.println(s1.getId());
System.out.println(s1.getName());
m1(s1);
System.out.println(s1.getId());
System.out.println(s1.getName());
}
public static void m1(Student s3){
s3.setId(10);
s3.setName("ranga");
s3=null;
}
}
In the above program we used new keyword only one time so entire program will have only one student object created.
Once we create object s1 is pointing to that object and its id,name values initialize with null values like the below screenshot.

When we execute the below code, it will return with null value.
System.out.println(s1.getId());//null
System.out.println(s1.getName());//null
When we call m1(s1); then Student s3=s1; then s3 reference also pointing to same object which is already referred by s1 reference. Look at the below image,

When we execute s3.setId(10); and s3.setName(“Ranga”); then s3 reference id value(null) override with 10 and name value(null) override with “Ranga”. Look at the below diagram,

When we do s3=null then it will lost the connection with that reference and m1 method execution is over because it doesn’t return anything because of it’s return type is void. Look at the below diagram,

The below diagram illustrates, that the previously setting s3 values are pointing to s1 because s3 lost connection with them.

Now it we print id and name of s1 reference, it will print id as 10 and name is “Ranga” because s1 is pointing to Student object which has the values of 10 and “Ranga”.
I hope this helped you to understand about references in Java. Let us know your thoughts. Happy Learning 🙂