This section clarifies the idea of breakpoints and in what way to set breakpoints in a program. A breakpoint announces an obvious stop or pause in the execution of a program at a specific line of code while debugging. It is valuable to obtain knowledge about variables in the program in its execution.
The following command sets up a breakpoint at a particular line number:
The resulting command sets up a breakpoint on a particular method or on a particular variable:
The resulting instance shows how to set up a breakpoint in a class.
Save the above file as Add.java. Compile this file using the following command:
Let us take an instance for debugging. Now, we start the debugging procedure by setting up a breakpoint on main (). Given underneath are the steps to be followed in the debugging process:
The following command starts a JDB session on the Add class for debugging:
The resulting command sets up a breakpoint on the main() method of Add class.
If the breakpoint is set magnificently, you get to see the following output:
The following command starts execution of the class Add:
If you execute this command, you get to see the resulting output. In this output, you find that the execution stops at the breakpoint position, that is at the main() function.
The execution stops at the first line of the main method, that is at "int a=5, b=6;" or Line no: 11 in the code. You can observe this information in the output.
The following command continues the program execution:
It provides you the remaining execution part and output as follows:
The Java Debugger (JDB) Related Interview Questions
|Adv Java Interview Questions||Core Java Interview Questions|
|JDBC Interview Questions||CorelDRAW Interview Questions|
|EJB(Enterprise JavaBeans) Interview Questions||Hibernate Interview Questions|
|Java Developer Interview Questions||Java Interview Questions|
|Java 8 Interview Questions||Advanced C++ Interview Questions|
|Apache Tomcat Interview Questions||Basic C Interview Questions|
|Java Programmer Interview Questions||Java 9 Interview Questions|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.