Entering two integers and returning a decimal fraction
import java.io.*;


It's often a bad practice to import everything in a package. this will clutter your IDE's Ctrl + Space functionality, and makes it harder for other people to see exactly which things you are using from a package.



/**
 * Class: GetRationalNumber


I like the Javadoc, but it's totally overkill to specify the class name in the javadoc. The class name is already displayed in the javadoc functionality itself, you don't need to duplicate that when you write javadoc.



int p, q;


Make it a habit ASAP to avoid one-letter variable names like these. numerator and denominator would be much better.



Possible improvement: Catch NumberFormatException (or use a regex in advance to make sure that it is a number, but that might a bit over your head right now).



System.out.println(
    "Divison by zero can cause serious trouble to the universe!"
);


I would write this on one line:

System.out.println("Divison by zero can cause serious trouble to the universe!");




System.exit(0);


The zero here indicates the exit status, which can be used by scripts and other stuff. If a program terminates normally, that is exit status zero. Is a possible division by zero really a normal program termination? In my opinion it is not. I would do System.exit(1); or System.exit(42); or something.



Overall, there's nothing object-oriented about what you have done, but I guess you haven't gotten that far yet, huh? :) Your code is quite fine for being beginner code. Now take it to the next level :)