Assertion error is JVM or Programmer Exception?

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
RRRRRR
Posts: 26
Joined: Sun Jul 23, 2017 2:13 am
Contact:

Assertion error is JVM or Programmer Exception?

Post by RRRRRR »

Firstly ->I wanted to ask that whether Assertion error is JVM or Programmer Exception?

Secondly -> When we don't write main method in our program and execute code then it gives like->

Error: Main method not found in class a.TestClass, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

So above is Error or Exception???

admin
Site Admin
Posts: 9522
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Assertion error is JVM or Programmer Exception?

Post by admin »

1. Thrown by the JVM when an assertion fails. Please read ExceptionClassSummary document given with our question bank.
2. The error message itself is quite clear. It is an Error.
If you like our products and services, please help us by posting your review here.

RRRRRR
Posts: 26
Joined: Sun Jul 23, 2017 2:13 am
Contact:

Re: Assertion error is JVM or Programmer Exception?

Post by RRRRRR »

Thank you very much. Ok next time i take care about it :)

jokovkilg
Posts: 1
Joined: Tue Nov 23, 2021 12:48 am
Contact:

Re: Assertion error is JVM or Programmer Exception?

Post by jokovkilg »

In Java, each application must have the main method. The main method is the entry point of every java program. The java program searches for the main method while running. This error occurred when the main method is not available. The reason that the compiler don't complain about the public is because it doesn't care about the main method. It doesn't take difference for it if a main exists or not. It's the JVM which need a start point public and static to launch your application.

So you should make your main method as public:

public static void main(String[] args)

The JVM is programmed to look for a specific signature for the main method before executing the program. It finds this signature by looking for a specific series of bytes in the bytecode. That signature only results from compiling a method that is - public static void main. If any of the three modifiers (public, static and void) are omitted the bytecode code will look different and the JVM will not be able to find your main method.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests