1111

1.What are the 3 characteristics of OOP.
Encapsulation, polymorphism and inheritance

2.What is polymorphism? Make an example.
Polymorphism is the provision of a single interface to entities of different types or the use of a single symbol to represent multiple different types.
e.g. An animal can be a cat or a dog.

3.What's the different between abstract class and interface.
1.Can answer in the syntax difference in Java.
2.Interface is a protocol, abstract class is a template.

4.What's the different between override and overload.
override - the relationship between superclass and subclass, method signature, args and return must be the same.
overload - same method names, at least one of the type, num, order different.

5.Ask the candidate to list some sorting algorithm.
bumble sort, quick sort, merge sort...

6.Ask a specific sorting algorithm implementation and the time/space complexity.
recommend ask those O(NlogN) algorithm

7.Compare quick sort and merge sort.
quick sort - O(Nlog2N) unstable
merge sort - O(NlogN) stable

8.Introduce how dynamic-programming work.

9.Ask the candidate to list some GoF design patterns.

10.Given a design pattern, ask how it works. Give an example from Java base module.
Recommend ask hard ones.
Bridge/Decorator/Visitor/Observer/Abstract Factory

11.Compare static proxy and dynamic proxy. How Java supports dynamic proxy?
InvocationHandle, CGLIB

12.What is the usage of annotation?
Allow to add metadata information into source code.
Should know the retention and target.
Use scenario: AOP

13.Compare Stack/Queue/Deque.
Stack - FILO
Queue - FIFO
Deque - Double ended queue, also can act as stack.

14.How Java implements the heap data structure.
PriorityQueue

15.When you can use a PriorityQueue?
Ordered queue, get the element with highest priority.

16.Compare ArrayList and LinkedList.
Random access or not.
ArrayList - get frequently
LinkedList - add/remove frequently

17.Why RandomAccess interface?
It decides use indexedBinarySerach(list,key) or iteratorBinarySerach(list,key) in List traversal.
ArrayList - for > iterator
LinkedList - iterator > for

18.How to iterate a HashMap?
for in entrySet(), entrySet().iterator()

19.HashMap vs ConcurrentHashMap
thread-safe or not

20.How to store elements in HashMap after Java 1.8+?
Array and red-black tree

21.Explain the red-black tree.

22.How to create a new async process in Java?
Thread, Runnable, Callable/Future/FutureTask...

23.Explain the sleep(), join(), yield() methods.
Focus on thread status, execute status.

24.Say something about CountDownLatch and CyclicBarrier.

25.Say something about Semaphore and Exchanger.

26.Say something about ThreadLocal
Per thread can access its own state copy.

27.What is ExecutorService?
Creating thread pool.

28.Different ways of create thread pool.
newFixedThreadPool(int nThreads)
newCachedThreadPool()
newSingleThreadExecutor()
newScheduledThreadPool(int corePoolSize)

29.What scenario can use a BlockingQueue?
Producer/consumer pattern.

30.What is the usage of volatile.
Thread lock. A lightweight synchronized.

31.Passive lock and optimistic lock in JDK.
sync, CAS

32.What is CAS mechanism?
Read the version, add lock, if failed, repeat read-compare-write.

33.IO vs NIO
Stream-oriented vs Buffer-oriented.
Blocked vs Non-blocked (base on selector).

34.File vs Path
Path is an advanced File, more features.

35.How to set the file permission in Java?
setReadable()/setExecutable()/setWritable()
PosixFilePermission

36.What is Optional?
Better handle the null check.

37.Say something about Stream.
Declarative programming, provides filter/sort/collectors...

38.How to iterate a Stream?
forEach()

39.What is the usage of Collectors?
Reduce operation. e.g Stream to Collection, aggregation.

40.How to statistic in a Stream?
summaryStatistics()

41.Pros of Lambda expression.
Anonymous, functional, argument passing, concise.

42.Any restriction of Lambda expression access outer variables?
final or effective final

43.How to make an interface be a Lambda?
Only ONE abstract method.
@FunctionalInterface is not a must.

44.Any approach of Database/SQL optimization
indexing, sharding, sql turning, use procedure

45.And difference of Oracle vs PostgreSQL/MySQL
any point on syntax, sequence, lock

46.inner join vs outer join
intersection vs union

47.How to implement distributed transaction?
Any framework, e.g. Seata, Fescar, IBM XA...
Use reverse operations.

48.MySQL vs MongoDB
Relational vs NoSQL. Compare data store, extension, transactions.

49.List the types of NoSQL databases
Key-value (Redis), Document-Oriented (MongoDB), Column-Family (Cassandra), Graph-Oriented (Neo4J)

50.MongoDB use scenarios
logging, data analysis

51.Redis use scenarios
cache, session, shopping cart

52.Redis persistence options
RDB (default), AOF

53.How Redis implements distributed lock?
setnx

54.What is cache avalanche, cache breakdown and cache penetration, how to avoid?
cache avalanche - data to be searched doesn't exist at DB and the returned empty result set is not cached as well and hence every search for the key will hit the DB eventually
cache breakdown - the cached data expires and at the same time there are lots of search on the expired data which suddenly cause the searches to hit DB directly and increase the load to the DB layer dramatically
cache penetration - lots of cached data expire at the same time or the cache service is down and all of a sudden all searches of these data will hit DB and cause high load to the DB layer and impact the performance

55.Spring Boot vs Spring (MVC)
Spring Boot: standalone, embed container, auto config, simply dependency, monitoring, ease of use...

56.How to enable auto config?
spring-boot-autoconfigure,@EnableAutoConfiguration

57.How to disable a specific config?
@SpringBootApplication(exclude=

58.What is starter?
A set of convenient dependency descriptors that you can include in your application.

59.List some common starters and their features.
spring-boot-starter-web, spring-boot-starter-data-jpa...

60.About spring.factories file in starter
Maps a name to different configuration classes which Spring Boot will try to run.

61.What is the Spring Boot standard configuration file?
application, bootstrap, .properties .yml

62.What config should place in bootstrap?
spring Cloud config, crypto key, any properties which couldn't be overridden.

63.Is yml supporting @PropertySource? NO

64.How to support multiple environment in Spring Boot?
application-xxx.yml, profile active

65.How to make Spring MVC xml file compliable in Spring Boot application?
@ImportResource

66.What is actuator?
Monitor and manage the Spring Boot application.

67.What benefit of using Spring Data JPA?
Reduce the development effort of DAO layer. Standardize the method name.

68.How to handle exception in rest controller?
ControlerAdvice, ExceptionHandler

69.What is Spring Cloud?
Provides tools for developers to quickly build some of the common patterns in distributed systems

70.Relationship of Spring Cloud and Spring Boot.
Actually no relationship, they are different parts of the Spring framework.

71.What is service registration and discovery?

72.List some service registration and discovery framework.
Eureka, Zookeeper

73.How to enable service discovery in Spring Boot application?
@EnableDisscoveryClient

74.How to enable load balance? List some load balance strategies.
@LoadBalanced Ribbon, Feign

75.Ribbon vs Feign

76.What is restful API?
Representational State Transfer.
Web service must provide its Web resources in a textual representation and allow them to be read and modified with a stateless protocol and a predefined set of operations.

77.What is resource under the context of rest API?
"Web resources" were first defined on the World Wide Web as documents or files identified by their URLs. Today, the definition is much more generic and abstract, and includes every thing, entity, or action that can be identified, named, addressed, handled, or performed in any way on the Web.

78.List the components of HTTP request.
action, uri, version, header, body

79.List the components of HTTP response.
status, version, header, body

80.HTTP action, PUT vs POST.
idempotent or not, PUT is idempotent

81.What is OPTIONS action mean?
List all available actions. Send the read-only request to server side.

82.In case the url is too long in a GET action, how to solve?
Use POST action instead.

83.Something about HTTP status code.
2xx, 4xx, 5xx meanings.

84.http vs https
Different port. https requires cert, secure transport.

85.soap vs rest
soap - protocol, xml, cacheable, app, slow, secure, sync/async, transactional, more bandwidth...
rest - architecture, xml/json/text, stateless, browser, quick, high performance, sync, non-transactional, less bandwidth...

86.MQ pros and cons
pros - decoupling, async, despiking
cons - low availability, high complexity

87.How to improve MQ availability? cluster

88.How to initialize a RestTemplate in Spring Boot application?
new RestTemplate(), RestTemplateBuilder

89.How to enable connection pool in RestTemplate instance?
Use PoolingHttpClientConnectionManager
RestTemplateBuilder pooled by default

90.Which is the best approach? Why? C
A. Every call new a RestTemplate()
B. Each remote call share a RestTemplate
C. All remote calls share a RestTemplate

91.What is the meaning of max per route? When need to config a bigger max per route? For example.
route: per client (ip) -> target url
batch, performance test

92.How to determine the JDBC connection pool size?
Actually, we don't need a large JDBC connection pool. It will be approximate the database server CPU core number.

93.How to enable the MQ connection pool?
1. JMS cache (preferred)
2. IBM MQ pool.
Plus: in IBM MQ, JMS cache will result in handler exhausted. Not sure our IBM MQ setting issue or other reason.

94.How to enable the Redis connection pool?
1. JedisPool
2. Lettuce (preferred)
Plus: if can compare the pros and cons of JedisPool vs Lettuce.

95.Compare the eviction policies.
volatile-lru, volatile-random, volatile-ttl
Plus: example of scenario use different policies

96.A heavy batch which loads and converts millions of data to database. How to make it no service downgrade at all?
1. multiple partitions for master table, live master partition #1
2. batch file -> staging table -> master partition #2
3. swap live partition of #1 and #2

97.Suppose a very lightweight gateway as message route which developed by Spring Boot. Many requests are 503 in peak time. Network, CPU and Heap are normal. Any other thing can check.
Check the tomcat server thread setting. Default is 200 thread with max 8192 connections.

98.Assume we have critical system such as stock trading app.
Service downgrade and many 503 in peak time (e.g. IPO 1st listing).
Not allow to scale due to time and resource constraints.
How to improve the customer experience.
1. circuit break instead of wait for 503
2. disable non-critical service in peak time

99.Suppose a downstream system developed by very old technology. If we have too many concurrent call it will response very slow or even down. How to handle?
1. self throttle control
2. use MQ for peak clipping

100.I want to migrate a monolithic to AWS, any suggestion.
1. how to IBM dependency
2. how to handle Oracle EE features
Refactor to micro service, cloud native, container e.g. docker.
1. IBM MQ to SAPI, ejb to micro service, get rid of XA transaction, MQ listener to Restful API
2. evaluate if can convert to cloud database, e.g. RDS, if not, keep on-premise
Plus: sensitive data, logging, handling

1.I want to migrate the Oracle Database to AWS RDS PostgreSQL, anything suggestion?
Sequence object to auto incensement PK, get rid of store procedure, use JPA…

2.How to consumer multiple remote call parallel in Spring Boot application?
1. @EnableAsync+Executor, @Async and return CompletableFuture
2. new ExecutorService and CompletionService. Must shutdown() ExecutorService

3.I use GET api but the URL too long, how to handle?
Use POST instead

4.My API is api/v1/xxx
1. I add a field on response body, need to change API url?
2. I add some new feature on the API, need to change API url?

1. NO, keep api/v1/xxx
2. keep both api/v1/xxx and api/v2/xxx

5.I have many application, but the SSL cert will be expiry with different date time and I always miss renewing the cert. How to improve?
1. share the SSL in multiple application
2. use cert management tool, e.g. Venafi

6.We have a online shopping system, we call billing system by MQ to deduct customer's money and then call product system to deliver products. Unfortunately, we find the product system have not enough product but we already deduct customer's money, how we can do?
1. if you use distributed transaction, then rollback the whole transaction
2. if no distributed transaction, use hold the customer's money first instead of deduct directly.
3. if no hold api on customer's money, use a reverse operation to refund

7.We MQ to handle customer's request async. Unfortunately, the volume is too large and the backend system is down. Many requests are pending in the queue. How to handle the pending data?
1. imagine if we resume the backend system with no change, the system will be down again.
2. create more instances with current limiting to consume the request instead of clear the queue direct.
3. after resume the service, scale up the service capability

8. Suppose another team want to access your production database for data analysis, they ask you to create a read-only schema for them. How to avoid database capability downgrade if they access our database.
1. create a read only view for them
2. create a database replica, with data sync in non critical hour

9.

10.

 

posted @ 2022-11-30 22:19  伐论大阀豪  阅读(194)  评论(0)    收藏  举报