Error in question enthuware.ocajp.i.v8.2.1406

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

Moderator: admin

Post Reply
Kyi Min Han
Posts: 1
Joined: Sun Jun 03, 2018 6:19 pm
Contact:

Error in question enthuware.ocajp.i.v8.2.1406

Post by Kyi Min Han »

What will the following code print when run?
public class Noobs {
public void m(int a){
System.out.println("In int ");
}
public void m(char c){
System.out.println("In char ");
}
public static void main(String[] args) {
Noobs n = new Noobs();
int a = 'a';
char c = 6;
n.m(a);
n.m(c);
}
}

Web test show me answer is “In int , In char” even if program can’t compile.

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

Re: Error in question enthuware.ocajp.i.v8.2.1406

Post by admin »

Assuming that you are talking about 2.1406, the question and the answer are correct. Please make sure you have typed the code exactly as given in the question.
If you like our products and services, please help us by posting your review here.

flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

Re: Error in question enthuware.ocajp.i.v8.2.1406

Post by flex567 »

There is no mention that

Code: Select all

int a = 'a';
char c = 6;
is implicit widening/narowing ?

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

Re: Error in question enthuware.ocajp.i.v8.2.1406

Post by admin »

Well, what do you think they are?
If you like our products and services, please help us by posting your review here.

flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

Re: Error in question enthuware.ocajp.i.v8.2.1406

Post by flex567 »

Code: Select all

int a = 'a'; //implicit widening
char c = 6; //implicit narrowing

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

Re: Error in question enthuware.ocajp.i.v8.2.1406

Post by admin »

Correct :)
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

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