MB6-704 · Question #50
You have a class named Classl thatcontains a static method namedsmethodl and an instance method named method2. Classl contains the following X+ + code: (Line numbers are included for reference…
The correct answer is B. Classl::smethodl (). Calling a Static Method In the following example, there is no need to first construct an instance of the SoftwareKey class before you call a static method on the class. To call the static method validateSoftwareKey, the syntax starts with the name of the class that contains the…
Question
You have a class named Classl thatcontains a static method namedsmethodl and an instance method named method2. Classl contains the following X+ + code: (Line numbers are included for reference only.) You need to callsmethodl from method2. Which code segment should you insert at line 10?
Options
- ACloss l.smethodl()
- BClassl::smethodl ()
- CThis::smethodl()
- DThis.smthodl()
How the community answered
(32 responses)- A6% (2)
- B72% (23)
- C19% (6)
- D3% (1)
Explanation
Calling a Static Method In the following example, there is no need to first construct an instance of the SoftwareKey class before you call a static method on the class. To call the static method validateSoftwareKey, the syntax starts with the name of the class that contains the method. A pair of colon (::) characters is used to connect the class name to the static method name. boolean yourBool = SoftwareKey::validateSoftwareKey (yourSoftwareKeyString);
Topics
Community Discussion
No community discussion yet for this question.