About Question enthuware.ocajp.i.v8.2.1012 :

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

Moderator: admin

Post Reply
Denyo1986
Posts: 38
Joined: Thu Jan 07, 2021 2:47 am
Contact:

About Question enthuware.ocajp.i.v8.2.1012 :

Post by Denyo1986 »

Code: Select all

Which lines contain a valid constructor in the following code?

public class TestClass{
   public TestClass(int a, int b) { } // 1
   public void TestClass(int a) { }   // 2
   public TestClass(String s); // 3
   private TestClass(String s, int a) { }     //4
   public TestClass(String s1, String s2) { }; //5
}
Does the semicolon in line 5 not make this option a wrong option?

Line 1 and 4 are clear. 2 is a method, 3 has no body.
Wouldnt line 5 be wrong?

Have never seen this before...


Maybe the idea is that we see a constructor and an empty statement, is that the case?

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

Re: About Question enthuware.ocajp.i.v8.2.1012 :

Post by admin »

Having a semicolon after the closing } at end of the method is not wrong. It is redundant but not wrong.
You can try it out.

Denyo1986
Posts: 38
Joined: Thu Jan 07, 2021 2:47 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1012 :

Post by Denyo1986 »

Yeah I did with big surprise :)
Tricky questions....good though :)

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests