Q1. current features of Java 8
--------------------------
1. forEach() method in Iterable interface
2. default and static methods in Interfaces
3. Functional Interfaces and Lambda Expressions
4. Java Stream API for Bulk Data Operations on Collections
5. Java Time API
6. Collection API improvements
7. Concurrency API improvements
8. Java IO improvements
9. Miscellaneous Core API improvements
Q2. what is stream API?
------------------------
Introduced in Java 8, the Stream API is used to process collections of objects. A stream is a sequence of objects that supports various methods which can be pipelined to produce the desired result.
Q3. what is the lambda expression?
----------------------------------
Lambda expression is a new and important feature of Java which was included in Java SE 8. It provides a clear and concise way to represent one method interface using an expression. It is very useful in collection library. It helps to iterate, filter and extract data from collection.
Q4. what is Collectors class?
----------------------------
Collectors is a final class that extends Object class. It provides reduction operations, such as accumulating elements into collections, summarizing elements according to various criteria, etc. It returns a Collector that produces the arithmetic mean of a double-valued function applied to the input elements.
Q5. what is generic in collection framework?
--------------------------------------------
A generic collection is strongly typed (you can store one type of objects into it) so that we can eliminate runtime type mismatches, it improves the performance by avoiding boxing and unboxing. Generic. Generic is the key concept to develop Generic collection.
What is the benefit of Generics in Collections Framework? Java 1.5 came with Generics and all collection interfaces and implementations use it heavily. Generics allow us to provide the type of Object that a collection can contain, so if you try to add any element of other type it throws compile time error
Q6. can we have try without catch?
----------------------------------
Yes, we can have try without catch block by using finally block. You can use try with finally. As you know finally block always executes even if you have exception or return statement in try block except in case of System. exit().
Q7. what is try with resources?
-------------------------------
Search Results
Featured snippet from the web
In Java, the try-with-resources statement is a try statement that declares one or more resources. The resource is as an object that must be closed after finishing the program. ... You can pass any object that implements java. lang. AutoCloseable, which includes all objects which implement java.
Q8. what is final keyword?
---------------------------
In the Java programming language, the final keyword is used in several contexts to define an entity that can only be assigned once. Once a final variable has been assigned, it always contains the same value.
Q9. what is the static keyword?
-------------------------------
In Java, static keyword is mainly used for memory management. It can be used with variables, methods, blocks and nested classes. It is a keyword which is used to share the same variable or method of a given class. Basically, static is used for a constant variable or a method that is same for every instance of a class.
Q10. what is the difference between HasMap and TreeMap?
-------------------------------------------------------
Q11. DI in Spring
-----------------
Q12. what is IOC
----------------
Q13. what is @Component?
------------------------
Q14. @ComponentScan
--------------------
Q15. RestTemplate
-------------------
Q16. how do you create Rest API?
-------------------------------
Q17. difference between Controller & RestController?
----------------------------------------------------
Q18. what is Spring Boot?
------------------------
Spring Boot is an open source Java-based framework used to create a micro Service. It is developed by Pivotal Team and is used to build stand-alone and production ready spring applications.
Q19. scope of a bean
---------------------
Q20. Prototype, Session
Q21. what is main controller in Spring Boot
Q22. Rest API what is you have to add in pom.xml
Q23. microservice
Q24. how do you consume a webservice?
Q25. how to change port no.?
Q26. what is hibernate?
Q27. if we are using Oracle and then we want to change it in mysql what change we have to do?
Q28. for production what we change in Spring Boot?
Q29. what is optional class in java?
Q30. how to we change port no. dynamically in Spring Boot?
Q31. difference between map and flatmap.
Q32. huge amount of data, collections.sort() or sql query, which better?
Q33. synchronized methods how many thread access at a time?
Q34. thread methods name?
| run() | Entry point for a thread |
| sleep() | suspend thread for a specified time |
| start() | start a thread by calling run() method |
| activeCount() | Returns an estimate of the number of active threads in the current thread's thread group and its subgroups. |
Q35. serializable
Q36.
===================================
// Java code illustrating iteration
// over map using forEach(action) method
import java.util.Map;
import java.util.HashMap;
class IterationDemo
{
public static void main(String[] arg)
{
Map<String,String> gfg = new HashMap<String,String>();
// enter name/url pair
gfg.put("GFG", "geeksforgeeks.org");
gfg.put("Practice", "practice.geeksforgeeks.org");
gfg.put("Code", "code.geeksforgeeks.org");
gfg.put("Quiz", "quiz.geeksforgeeks.org");
// forEach(action) method to iterate map
gfg.forEach((k,v) -> System.out.println("Key = "
+ k + ", Value = " + v));
}
}
// Java program to demonstrate iteration over
// Map using keySet() and values() methods
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
class IterationDemo
{
public static void main(String[] arg)
{
Map<String,String> gfg = new HashMap<String,String>();
// enter name/url pair
gfg.put("GFG", "geeksforgeeks.org");
gfg.put("Practice", "practice.geeksforgeeks.org");
gfg.put("Code", "code.geeksforgeeks.org");
gfg.put("Quiz", "quiz.geeksforgeeks.org");
// using iterators
Iterator<Map.Entry<String, String>> itr = gfg.entrySet().iterator();
while(itr.hasNext())
{
Map.Entry<String, String> entry = itr.next();
System.out.println("Key = " + entry.getKey() +
", Value = " + entry.getValue());
}
}
}
============================================
// Java program to demonstrate the
// creation of Set object using
// the TreeSet class
import java.util.*;
class GFG {
public static void main(String[] args)
{
Set<String> ts
= new TreeSet<String>();
// Adding elements into the TreeSet
// using add()
ts.add("India");
ts.add("Australia");
ts.add("South Africa");
// Adding the duplicate
// element
ts.add("India");
// Displaying the TreeSet
System.out.println(ts);
// Removing items from TreeSet
// using remove()
ts.remove("Australia");
System.out.println("Set after removing "
+ "Australia:" + ts);
// Iterating over Tree set items
System.out.println("Iterating over set:");
Iterator<String> i = ts.iterator();
while (i.hasNext())
System.out.println(i.next());
}
}
===========================================================
// Java program to Reverse a String using ListIterator
import java.lang.*;
import java.io.*;
import java.util.*;
// Class of ReverseString
class ReverseString {
public static void main(String[] args)
{
String input = "Geeks For Geeks";
char[] hello = input.toCharArray();
List<Character> trial1 = new ArrayList<>();
for (char c : hello)
trial1.add(c);
Collections.reverse(trial1);
ListIterator li = trial1.listIterator();
while (li.hasNext())
System.out.print(li.next());
}
}
================================================================
Q.what is the use of immutable class in java?
Immutable classes make concurrent programming easier. Immutable classes make sure that values are not changed in the middle of an operation without using synchronized blocks. By avoiding synchronization blocks, you avoid deadlocks.
Immutable objects are thread-safe so you will not have any synchronization issues. Immutable objects are good Map keys and Set elements, since these typically do not change once created. Immutability makes it easier to parallelize your program as there are no conflicts among objects.
Q. What does thread safe mean in Java?
Simply , thread safe means that a method or class instance can be used by multiple threads at the same time without any problems occurring.
The rule of thumb is to never ever use async for live data read and never ever use sync for business-critical write transactions unless you need the data immediately after write.
Embed additional authentication data/ token into all HTML forms
Q. Why does iterator remove Do not throw ConcurrentModificationException?
ConcurrentModificationException is not thrown by Iterator. remove() because that is the permitted way to modify an collection while iterating. ... Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next().
Q. What is Kafka and why it is used?
Kafka is a distributed streaming platform that is used publish and subscribe to streams of records. Kafka is used for fault tolerant storage. Kafka replicates topic log partitions to multiple servers. ... Kafka is used to stream data into data lakes, applications, and real-time stream analytics systems.
Q. What is Kafka in simple words?
Kafka is an open source software which provides a framework for storing, reading and analysing streaming data. Being open source means that it is essentially free to use and has a large network of users and developers who contribute towards updates, new features and offering support for new users.
RabbitMQ is a general purpose message broker that supports protocols including, MQTT, AMQP, and STOMP. ... Kafka is a durable message broker that enables applications to process, persist and re-process streamed data. Kafka has a straightforward routing approach that uses a routing key to send messages to a topic.
how to create custome expception in REST API [@RequestBody, @Valid]
how to create field validation in REST API
how to pass the value in REST API to get the object
ConstraintValidator
ResponseEntityExceptionHandler
Global Exception
----------------
@ControllerAdvice
@ExceptionHandler
# Whether to enable the default error page displayed in browsers in case of a server error.
server.error.whitelabel.enabled=false
src/main/resources/application.properties
spring.mvc.view.prefix= /WEB-INF/pages/
spring.mvc.view.suffix= .jsp
<!-- https://mvnrepository.com/artifact/org.springframework.kafka/spring-kafka -->
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.6.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-bus-amqp -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
<version>1.0.0.RC2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.4.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-eureka-server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-zuul -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-client -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-sleuth-zipkin -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-hystrix -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>1.4.4.RELEASE</version>
</dependency>
COMPUTING
a record of the contents of a storage location or data file at a given time.
"the procedure takes a new snapshot and does pixel counts for various sub-areas"
Interview 15.01.21
==================
1. any idea about Jenkin Continuous integration/continuous delivery (CI/CD)
2. troubleshooting production issues, how to solve the problem any tools you have used, and how to debugging?
3. Java 8 popular features
4. what is mean by sam interfaces ? (An interface having only one abstract method is known as a functional interface and also named as Single Abstract Method Interfaces (SAM ))
5. How multiple inheritance works in Java?
6. How to detect the deadlocks how to fix that deadlocks?
7. difference between no class found error and class not found exception
ClassNotFoundException is an exception that occurs when you try to load a class at run time using Class. forName() or loadClass() methods and mentioned classes are not found in the classpath. NoClassDefFoundError is an error that occurs when a particular class is present at compile time, but was missing at run time.
8. Why String is immutable?
Why String Is Immutable? In Java, String is a final and immutable class, which makes it the most special. It cannot be inherited, and once created, we can not alter the object. String object is one of the most-used objects in any of the programs.
9. StringBuilder Vs StringBuffer
10. what is synchronization with respect to multithreading
11. how can we override the main method?
In short, the main method can be overloaded but cannot be overridden in Java. That's all about overloading and overriding the main method in Java. Now you know that it's possible to overload main in Java but it's not possible to override it, simply because it's a static method.
12. default methods of an object
13. difference between abstract class and interface
14. SOLID Principle in Java
Principle Description
Single Responsibility Principle Each class should be responsible for a single part or functionality of the system.
Open-Closed Principle Software components should be open for extension, but not for modification.
Liskov Substitution Principle Objects of a superclass should be replaceable with objects of its subclasses without breaking the system.
15. what is meant by reflection
Java Reflection is the process of analyzing and modifying all the capabilities of a class at runtime. Reflection API in Java is used to manipulate class and its members which include fields, methods, constructor, etc
16. difference between interface and java 8 interface
17. what are the design pattern you have used?
18. what are the steps we should follow to connect the DB?
Step 1 - Add dependency for your database connector to pom. xml. ...
Step 2 - Remove H2 Dependency from pom.xml. Or atleast make its scope as test. ...
Step 3 - Setup your My SQL Database. ...
Step 4 - Configure your connection to Your Database. ...
Step 5 - Restart and You are ready!
19. query annotation in Hibernate
20. use of @Query
21. what is meant by AOP
22. realtime example you have used AOP
23. which tools you have used to test REST API
24. Advantages of Postman
25. unit testing, mokito
26. in security CSRF oath for Authentication
27. what is the annotation being used for CSRF
28. Spring IOC and DI
29. How Spring MVC works
30. What are idempotent and/or safe methods in REST API
31. difference between bean factory and application context
32. what are the REST methods
The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT, PATCH, and DELETE. These correspond to create, read, update, and delete (or CRUD) operations, respectively. There are a number of other verbs, too, but are utilized less frequently.
33. when singleton is not a singleton class in java
A singleton (in Java land) wouldn't work as a singleton if a given class is loaded by multiple class-loaders. Since a single class can exist (or can be loaded) in multiple classloaders, it's quite possible to have "multiple" instances of a "supposedly" singleton class for a given JVM instance.
34.what is dispatcher servlet do in spring
35. webpage website webserver
36. advantages of hibernate over JDBC
37. what is meant by lazy loading in hibernate
38. difference between save and persist method in hibernate
39. n+1 select problem in hibernate
40. types of cache in hibernate (1st level, 2nd level and query cache)
41. does SessionFactory thread safe in hibernate? yes
42. alternate ORM tools other than hibernate (MyBatis, Spring JPA)
43. how we can log hibernate query
44. differentiate spring and springboot
45. springboot without spring
46. springboot application anotation
47. how will you configure that JETTY <exclusions>
48. how do you connect springboot data base write JPA
49. how to chang the port no.
50. what are the different annotation available in springboot
51. what is mean by actuator?
52. spring boot security
53. how microservice help other than normal service
54. difference between SOA and microservice architecture?
55. what are the best practice to design a microservices
N-MS3090TRIO-X
interview 18.01.21
==================
1. how to hadle expection in Angular
2. how to write stored procedure query in Hibernate?
3. How to hadle Global error in Angular
4. how to write query/ fetching data in microservices
5. how to reduce load time in angular
6. how to write custome directive in angular
interview 19.01.21
==================
List <String> wordsList = Lists.newArrayList("hello", "bye", "ciao", "bye", "ciao");
{ciao=2, hello=1, bye=2}
Map<String, Long> collect = wordsList.stream().collect(groupingBy(Function.identity(), counting()));
synchonized HashMap and concurrent HasMap
can we write a method final? only constructor
class A{}
class B extends A{}
class c extends B {}
object lock
class lock
When the parent class method throws one or more checked exceptions, the child class method can throw any unchecked exception.
systempropertiesadvanced 18/01/21 12:47pm
Java Specification Requests (JSRs) are the actual descriptions of proposed and final specifications for the Java platform. At any one time there are numerous JSRs moving through the review and approval process.
call by value and call by reference
reference variable in java
constructor and destructor
class load
garbage collection
Model ModelView ModelAndView
can we override static method? No
can we run without main method in java?
Yes, we can execute a java program without a main method by using a static block. Static block in Java is a group of statements that gets executed only once when the class is loaded into the memory by Java ClassLoader, It is also known as a static initialization block.
concurrency execution standard
how HashMap internally work?
How set internally work?
difference between run() and start().
validation on entity, request, response.
@Qualifier
401,403
payload
how run jar file in command prompt
Run executable JAR file
Go to the command prompt and reach root folder/build/libs.
Enter the command: java –jar <ExecutableJarFileName>.jar.
Verify the result. Post navigation.
https://www.bootdey.com/bootstrap-themes/page:3?q=business
Fail Fast and Fail Safe Iterators in Java
concurrent hashmap
facade
query for object and query for list
ibaties,spring jdbc template [resultset map, non-normilize database] hibernate [normalize database] [DAO design pattern]
no sql database [casecandra]
microservice design pattern
reflection package in java
how reflection package use in spring []
Docker architecture [ref sourav sharma]
predicate
propagation
Spring Integration provides an extension of the Spring programming model to suppoort the well known Enterprise Integration Patterns. It enables lightweight messaging within Spring-based applications and supports integration with external systems through declarative adapters. Those adapters provide a higher level of abstraction over Spring’s support for remoting, messaging, and scheduling.
RabbitMQ is an open source message broker software. It accepts messages from producers, and delivers them to consumers. It acts like a middleman which can be used to reduce loads and delivery times taken by web application servers
The double colon (::) operator is known as the method reference in Java 8. Method references are expressions which have the same treatment as a lambda expression, but instead of providing a lambda body, they refer to an existing method by name. This can make your code more readable and concise.
Q. can we declare a constructor in a Abstract class?
Q. can we create a instance of a Abstract class?
Q. what are the names of a functional interface in Java 8?
Q. Instance of a Block
What is lifecycle hook in angular?
Your application can use lifecycle hook methods to tap into key events in the lifecycle of a component or directive in order to initialize new instances, initiate change detection when needed, respond to updates during change detection, and clean up before deletion of instances.
what is intermediate operations and what is terminal operations
This answer is not useful
From the jQuery documentation: you specify the asynchronous option to be false to get a synchronous Ajax request. Then your callback can set some data before your mother function proceeds.
Here's what your code would look like if changed as suggested:
beforecreate: function (node, targetNode, type, to) {
jQuery.ajax({
url: 'http://example.com/catalog/create/' + targetNode.id + '?name=' + encode(to.inp[0].value),
success: function (result) {
if (result.isOk == false) alert(result.message);
},
async: false
});
}
Q. Disadvantages of Angular
Q. validation of POJO class
xms jvm
- autowire byName – For this type of autowiring, setter method is used for dependency injection. ...
- autowire byType – For this type of autowiring, class type is used.
@Import
How to import different library in a calling class
How to differentiate two same type objects?
double layer locking in singleton
opensession and current session in hibernate
What is the difference between observable and promises?
Promises deal with one asynchronous event at a time, while observables handle a sequence of asynchronous events over a period of time.
What is difference between subscribe and observable?
Promises provide one. This makes observables useful for getting multiple values over time. Observables differentiate between chaining and subscription.
Lombok java without setter & getter
Spring security
https://youtu.be/wVc_ilWtA6g
SonarLint
Spring Assistance
Maven Helper
The Four Principles of Object-Oriented-Programming (OOP):
Encapsulation. Encapsulation is accomplished when each object maintains a private state, inside a class. ...
Abstraction. Abstraction is an extension of encapsulation. ...
Inheritance. ...
Polymorphism.
Q. HashMap having same hascode
Q. select Table A (10 rows) x Table B (20 Rows)
Q. what is the view in Oracle DB
Q. remove the duplicate from list and maintains the order also
4 Answers. @QueryParam is a JAX-RS framework annotation and @RequestParam is from Spring. I'll try to shed some more detailed light on this question. ... annotation) , represents the parameter of HTTP request, and to be clear here, it doesn't specify which type of parameter it is - query, header, body or etc
what is xms, xmx?
Java Parallel Array Sorting Example
Output:
5 8 1 0 6 9 Array elements after sorting 0 1 5 6 8 9
0 Comments