Question 1. How Do You Check Your Java Process Is Running On Linux?
You can test by means of using "playstation " command and "grep" command e.G. Playstation grep "myprocess". The key-word which you use with grep for search can be anything precise to your process, some thing which appears in its command line e.G. Call of the elegance which implements the principle approach. You can also do "playstation -ef list all Java process.
Question 2. How Do You Check How Much Memory And Cpu Your Java Process Is Consuming?
First, you want to discover the PID of your technique, which you can discover by using using the "ps" command as shown within the previous question. Once you find the PID you may use the "pinnacle" command to find the CPU and memory utilization. Alternatively, you can additionally use the prstat command as shown here.
Java Script Interview Questions
Question 3. What Does -xmx And -xms Parameters Mean?
These are parameters to specify heap size in Java. The -Xms defines the size of the heap when JVM starts up and -Xmx is used to specify the most heap size for Java utility i.E. Your heap can't develop beyond that and JVM will die by means of throwing OutOfMemoryError in case your heap doesn't have enough area to create new objects. See here to learn more about heap memory in Java.
Question 4. What Is The Difference Between Jvm And Jre?
The JRE stands for Java Runtime Environment and JVM stands for Java Virtual Machine. You set up JRE to run Java application e.G. Applet or Core Java application or Web server like Tomcat. The JVM is a part of JRE. See here to analyze more differences between JVM and JRE.
Java Script Tutorial
Question five. What Is The Difference Between Jvm And Jit?
The JVM stands for Java Virtual gadget while JIT stands for Just in time Compiler. The JIT is part of JVM and used to convert the Java bytecode into local machine code which runs quicker. There is a few threshold set if a code runs greater than the brink it will become the candidate of simply in time compilation by means of JIT.
Adv Java Interview Questions
Question 6. How Do You Take The Heap Dump Of A Java Process?
There are many methods to take the heap unload of a Java technique e.G. Tomcat, but maximum commonplace is by the usage of gear available in JDK e.G. JVisualVM, jCmd, and jmap. Here is the command you could use to take the heap sell off of Java procedure:
$ jmap -sell off:stay, file=/area/of/heap_dump.Hprof PID
The heap sell off will comprise all live objects and they're saved in heap_dump.Hprof record. Remember, you also want PID of Java procedure which you may locate by way of the usage of "playstation " and "grep" command as discussed in the first query. You can see Java Performance Companion through Charlie Hunt to learn more approximately taking and analyzing heap unload in Java to find reminiscence leak and different memory related errors.
Question 7. How Do You Take A Thread Dump Of A Java Process?
Taking thread unload is less complicated than taking heap sell off due to the fact you do not need to bear in mind tool. In Linux, you can simply use the kill command to take the thread dump e.G.
$ kill -three PID
will print the thread dump inside the log document or wherein System.Out is redirected. Similarly, in Windows, you could use Ctrl + Break from the command set off. Alternatively, you could also use jConsole and VisualVM to take the thread sell off of Java utility in both Windows and Linux. You can also examine Java Performance The Definitive Guide By Scott Oaks to analyze greater about thread sell off and heap dump.
Adv Java Tutorial J2SE Interview Questions
Question eight. What Is Outofmemoryerror In Java? How Do You Deal With That?
The Java digital system throws java.Lang.OutOfMemoryError when there isn't sufficient reminiscence to run the utility e.G. No extra memory to create new items, no greater reminiscence to create new threads and so on. The most common OutOfMemoryError is the java.Lang.OutOfMemoryError: java heap space, which comes whilst there's no more reminiscence left to create a new object.
Question nine. What Is The Difference Between 32-bit And 64-bit Jvm?
The essential differences between 32-bit and sixty four-bit JVM are that later is designed for 64-bit operating gadget e.G. Windows eight or later versions of Linux. From Java developer's perspective, the primary distinction between them comes from heap length. A sixty four-bit JVM sincerely has limitless heap reminiscence as compared to 4GB of the theoretical limit of 32-bit JVM. If your software wishes more reminiscence, higher run it on 64-bit JVM with big heap area. See here to analyze more approximately 32-bit and 64-bit JVM.
Core Java Interview Questions
Question 10. What Is Garbage Collector?
The rubbish collector is a component of Java digital gadget which is responsible for reclaiming reminiscence from dead items. It's one of the key components and lets in an utility developer to consciousness on application improvement instead of doing memory control. Some of the famous rubbish collectors are a Concurrent Mark-Sweep rubbish collector and G1 garbage collector in recent times.
Core Java Tutorial
Question 11. How Do You Analyze A Heap Dump?
There are many tools to analyze heap dump in Java e.G. You may use the jhat tool which comes in conjunction with JDK. You also can use Eclipse Memory Analyzer to analyze heap sell off to find out any reminiscence leak in Java whilst coping with OutOfMemoryError in Java. See Java Performance The Definitive Guide By Scott Oaks to research greater about reading Java Heap dump.
Java Struts Interview Questions
Question 12. What Is The Difference Between Web Server And Application Server?
The most important distinction among Web and Application Server comes from the reality which you can't run EJB on the Web server like Tomcat or Jetty. The application server like WebLogic and WebSphere gives the runtime surroundings for EJB and different superior services required via Java EE or J2EE specification.
Java Script Interview Questions
Question thirteen. What Is The Difference Between Apache Httpd And Tomcat?
Though both httpd and Tomcat are products of Apache software program basis, the httpd is extra popular and used throughout the net and now not just in Java world. The httpd is an internet server which could serve static HTML documents and dynamic content material the use of PHP, Perl or Python, whilst Tomcat is a Servlet field which provides the runtime environment for Servlet and JSP. You also can use each Apache httpd and Tomcat together in Java global.
Question 14. Can You Use Apache And Tomcat Together?
Yes, you could use Apache and Tomcat together. There are many Java web utility that is fronted through Apache net server to supply static sources e.G. HTML documents, pictures, configuration files and many others. You can then configure Apache to ahead the request to Tomcat.
Question 15. How Do You Start And Stop Tomcat In Linux?
When you install Tomcat in Linux via unzipping the downloaded package deal, you may see that there is a startup.Sh and shutdown.Sh report inside the tomcat/bin directory. These scripts are used to start and prevent Tomcat in Linux. These scripts internally name Catalina.Sh, the primary script to begin Tomcat engine.
Hibernate Interview Questions
Question sixteen. How Do You Start And Stop Apache On Linux?
The Apache server runs as httpd daemon in Linux and you could both use kill command after locating the PID of httpd method as proven right here or you can use the apachectl script as proven under to begin and forestall Apache web server in Linux
Starting Apache net server in Linux
$ apachectl start
Stopping Apache internet server in Linux
$ apachectl prevent
Restarting Apache internet server in Linux
$ apachectl restart
/sbin/service httpd restart
You may want root get entry to to do if Apache web server is not strolling to your application account.
JavaServer Faces (JSF) Tutorial
Question 17. What Is The Difference Between Jdbc And Jndi?
As I said in the preceding answer, the JDBC stands for Java Database Connectivity and affords APIs and pointers to attach a database from Java, while JNDI stands for Java Naming and Directory Interface and provides a logical shape for retrieving resources e.G. Database, messaging queues, enterprise Java beans without understanding their physical region e.G. Host or port. You can sign up a resource with JNDI after which relaxation of your application component can get entry to them using JNDI call. The database connection pool is the most common resource accessed via JNDI in net servers like Tomcat or WebLogic.
JavaServer Faces (JSF) Interview Questions
Question 18. What Is Database Connection Pool?
As it name indicates, it just a pool of database connections. Since creating a new database connection in actual-time is an pricey process and might probably sluggish down the response time, many utility keeps a pool of active database connection. When a request is available in they retrieve a connection from the pool, get the records from the database after which go back the relationship returned to pool in order that it can be reused. This way, response time is advanced in most of the Java internet application. See right here to setup a database connection pool in Tomcat the use of Spring framework.
Adv Java Interview Questions
Question 19. Your Java Application Is Connected To A Database Via A Connection Pool. Suddenly Your Database Goes Down? Is That An Issue With Your Java Application? Do You Need To Restart Your Java Application?
trace: Since your Java utility is the usage of a connection pool, it has lively connections to database which will get disconnected as soon as DB is going down. If you try to execute a query, you'll get hold of Socket mistakes.
Java 8 Tutorial
Question 20. How Do You Send Web Service Request From Linux?
There are some commands available in Linux e.G. Curl and wget which allows you to ship HTTP commands, which you could use to name and check your web offerings from Linux. Particular, Curl is used extensively to test RESTful Web Services due to the fact it is able to send POST request, GET request, request with headers and additionally authenticate the usage of each primary and digest authentication.
If you're working with REST API, I propose learning curl, it's very convenient to test in case your API is running nicely the use of curl from the command line. You may even write a script to automate the ones stuff.
Java 8 Interview Questions
Question 21. What Is The Difference Between Http And Https?
This is one of the common and easy questions. Of path, you recognize the difference among HTTP and HTTPS right? Properly, HTTP is insecure however HTTPS is comfortable, the more "s" is for safety, this means that it now not simplest encode and encrypt the message before sending however additionally affirm the identification of the server through the usage of SSL certificate furnished by using global certificate authorities e.G. GoDaddy, Thawte, VeriSign, Digicert, GeoTrust, and Comodo. See right here to study more how SSL and Certifications paintings in Java internet utility.
Question 22. What Is The Difference Between The Get And Post Method?
Another easy but frequently asked query on Java guide interviews. The foremost distinction between the GET and POST is that GET is each idempotent and safe but POST isn't always. You can fire GET request more than one time and it'll supply the identical end result but a couple of POST submission have to usually be prevented. GET is likewise used to read statistics from server and POST is used to ship statistics to the server.
Question 23. What Is The Difference Between Servlet And Jsp?
This is any other exciting Java JEE support Interview Question. Even even though each Servlet and JSP is used to create dynamic HTML the important thing difference among them is their purpose. Servlet is supposed for Java developers and also you write greater Java than HTML and that is why it serves as Controller in lots of popular MVC framework e.G. DispatcherServlet in Spring MVC.
On the alternative hand, JSP is designed for HTML builders and it is greater HTML than Java and that is why it's far used as "view" in MVC frameworks like Spring and Struts. See the link in the solution for extra specified contrast.
JavaFX Interview Questions
Question 24. What Is The Difference Between Struts And Spring Mvc?
This is again a popular and often asked query on Java JEE Interviews. Even although each are famous web MVC framework for Java programs, the key distinction is that Spring brings dependency injection first and Struts brings it later the usage of Struts 2.0.
Spring is also a collection of libraries e.G. You get Spring Security to put into effect safety in your utility, then there's Spring Boot, Spring Data, Spring Cloud and many extra beneficial libraries below Spring umbrella.
J2SE Interview Questions
Question 25. What Is The Difference Between Jdbc And Hibernate?
There are many variations between JDBC and Hibernate however the maximum vital one is that JDBC presents an API to hook up with the database and execute the query but Hibernate is an ORM (Object Relational modeling) framework, which means that it allows you to work with items while it takes care of saving and retrieving item from database.
In quick, in JDBC you want to put in writing SQL queries to get and shop data from database however in Hibernate you simply address items, Hibernate looks after issuing SQL queries to the database.
Question 26. What Is The Difference Between Stack Memory And Heap? Which One Is Faster?
These are just specific reminiscence areas used to keep extraordinary sorts of variables. The stack is local to each thread while heap reminiscence is shared amongst all threads. Since Stack is towards thread and generally carried out using CPU registers they are faster than heap memory. The stack is used to store local variables as nicely technique name frames even as heap is used to store gadgets and sophistication metadata. See the detailed answer for more factors.
NHibernate Interview Questions
Question 27. Your Java Application Is Connecting To Another Java Application (server) Running On The Remote Host And Listening On Port 17865. Now, You Don't Have Access To That Remote Host To Go And See If The Process Is Running. How Do Find If The Server Is Up And Running?
you could use the telnet command.
Core Java Interview Questions
Question 28. You Are Supporting A Java Web Application Which Connects To Many Core Java Process And Gets Data From Them To The Distribution To Clients? One Client Complains That The Request For Data Is Taking Too Long And It's Almost Like Hung? How Do You Troubleshoot This Problem?
check the log, take a look at database, take a look at the file machine
Spring MVC Framework Tutorial
Question 29. The Java Application You Support Connects To A Database Via A Dns, Which Automatically Switches To The Secondary Database Server When The Primary Goes Down. You Find That In The Event Of A Failover, Your Java Application Is Not Connecting To Secondary Db Server? How Do You Troubleshoot This Problem?
take a look at which model your Java application is running. Some JRE caches the DNS e.G. JRE 1.6
Spring MVC Framework Interview Questions
Question 30. What Is A Deadlock? How Do You Find If Your Java Program Has A Deadlock?
The impasse is a situation that may arise between or a couple of threads. In this case, every of the thread waits for every different and can not development. In Java, this normally occurs when thread 1 holds the lock required by means of thread 2 and thread 2 holds the lock required by using thread 1. If your Java application is hung then it could be a deadlock. You can take a thread dump and find out if any thread is awaiting the lock preserve by means of other and vice-versa. You also can use jConsole device to locate impasse.
Question 31. What Is The Race Condition?
The race circumstance is another multithreading and concurrency computer virus which occurs because of racing between threads, as an instance, if one thread is updating a variable and 2d thread tries to read the value before it finished. You can keep away from race situations via properly synchronizing your code.
The Java Debugger (JDB) Tutorial
Question 32. What Is The Difference Between Path And Classpath?
Both are key surroundings variable utilized by Java platform, but the key distinction among them is that PATH points to the JDK binaries or local libraries e.G. Java.Exe, whilst CLASSPATH factors to Java binaries e.G. JAR documents, which contains bytecode. PATH is also gadget stage idea independent of Java however CLASSPATH is only Java idea and used by JVM to load instructions required by way of Java software you're jogging.
The Java Debugger (JDB) Interview Questions
Question 33. How Do You Find The Java Version Used By Your Application?
You can run the java -model command in the command activate to find out the version of Java used by your application. If you have got multiple JDK or JRE hooked up then make sure you operate the only that is utilized by your software.
Java Struts Interview Questions