About Question enthuware.ocpjp.v11.2.3667 :

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

Moderator: admin

Post Reply
Stranko
Posts: 2
Joined: Wed Jul 21, 2021 11:25 am
Contact:

About Question enthuware.ocpjp.v11.2.3667 :

Post by Stranko »

Hi everyone,

Code: Select all

Incorrect response n1

ps.setNull(3, JDBCType.INTEGER); 
ps.setNull(4, JDBCType.STRING); 

The second parameter to the setNull method is of type int and it expects the value to be one of the constants defined in java.sql.Types class. Among other constants, [b]it has INTEGER and VARCHAR for int and String values respectively. STRING is not a valid constant in this class[/b].  java.sql.JDBCType also defines the same names (i.e. INTEGER and VARCHAR, among others) but it is an enum.
 
Incorrect response n2

ps.setNull(3, JDBCType.INTEGER); 
ps.setNull(4, [b]JDBCType.VARCHAR[/b]);

[b]This is wrong for the same reason as above[/b].
I'm sorry but this explanation doesn't make sense to me. "it has INTEGER and VARCHAR for int and String values respectively" vs second response being wrong despite having exactly VARCHAR described there?

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

Re: About Question enthuware.ocpjp.v11.2.3667 :

Post by admin »

Please read the explanation carefully. The difference is in the name of the type in which INTEGER and VARCHAR are declared. i.e. Types.VARCHAR vs JDBCType.VARCHAR

Types.VARCHAR is an int while JDBCType.VARCHAR is an enum.

That is why the explanation says:
The second parameter to the setNull method is of type int and it expects the value to be one of the constants defined in java.sql.Types class.
If you like our products and services, please help us by posting your review here.

Stranko
Posts: 2
Joined: Wed Jul 21, 2021 11:25 am
Contact:

Re: About Question enthuware.ocpjp.v11.2.3667 :

Post by Stranko »

Alright, that clears it up, must have been too tired when reading the explanation.

Thanks :)

Post Reply

Who is online

Users browsing this forum: No registered users and 63 guests