What is the terminology for each expression in the following class :
for e.g :
class Test {
    int a=0;
    void method(boolean boo){
        String b="";
        try
        {
            new Thread().sleep(1000);
        }
        catch(InterruptedException e){}
        JOptionPane.showMessageDialog(null,"test");
        BufferedImage image=ImageIO.read(new File("C:\\file.png"));
    }
}
From what i know a is a field, boo is a parameter, b and image are local variables.
What is the terminology used for
new Thread().sleep()JOptionPane.showMessageDialog()ImageIO.read()new File()InterruptedException
                        
new Thread().sleep():This is a two-part expression. The first part i.e,
new Thread()is actually documented in the Java Language Specification (JLS) as an unqualified class instance creation expression :You basically create an instance of the
Threadclass when you saynew Thread(). The second part of the statement is.sleep()which is known as a method call.new File():This is also an unqualified class instance creation expression just like the expression
new Thread()but creates an instance of theFileclass instead of theThreadclass.JOptionPane.showMessageDialog():If you take a look at the source code for the JOptionPane.showMessageDialog method, you will see that the method is a
staticmethod. Also, the JLS explains how to access static methods :What the JLS indirectly says is that you can access a
staticmethod outside the class in which it is defined using the name of the class.Another important fact to understand here is that there are well defined Java naming conventions.
XyzAbc, assume that it is either aclassor aninterface. For example,JOptionPaneandImageare class names.doSomething,getSomething,setSomething,showMessageDialog().. you should know that it is a method.Putting all this understanding together, we can deduce that
JOptionPane.showMessageDialog()calls astaticmethod fromJOptionPane.InterruptedException:If you understood the naming conventions explained above, you should know by now that
InterruptedExceptionis aclass. How it differs from any other class inJavais that it can be thrown around using thethrowclause and then caught using atry-catchstatement. You can read more about exception handling in the Oracle documentation.