Tag Archives: string

Given the code fragment: String name = "Spot"; int age = 4; String str ="My dog " + name + " is " + age;

Given the code fragment:String name = “Spot”;int age = 4;String str =”My dog ” + name + ” is ” + age;System.out.println(str);AndStringBuilder sb = new StringBuilder();Using StringBuilder, which code fragment is the best potion to build and print the followingstring My dog Spot is 4 A. sb.append(“My dog “).append( name ).append(” is ” ).append(age); System.out.println(sb); B. sb.insert(“My dog… Read More »

Given: class Overloading { int x(double d) { System.out.println("one"); return 0; } String x(double d)

Given:class Overloading {int x(double d) {System.out.println(“one”);return 0;}String x(double d) {System.out.println(“two”);return null;}double x(double d) {System.out.println(“three”);return 0.0;}public static void main(String[] args) {new Overloading().x(4.0);}}What is the result? A. Three B. One C. Two D. Compilation fails. Correct Answer: D

Given: String originalPath = "data\\projects\\a-project\\..\\..\\another-project"; Path path = Paths.get(originalPath);

Given:String originalPath = “data\\projects\\a-project\\..\\..\\another-project”; Path path = Paths.get(originalPath); System.out.print(path.normalize()); What is the result? A. data\another-project B. data\projects\a-project\another-project C. data\\projects\\a-project\\..\\..\\another-project D. data\projects\a-project\..\..\another-project Correct Answer: D

Given: String originalPath = "data\\projects\\a-project\\..\\..\\another-project"; Path path = Paths.get(originalPath);

Given:String originalPath = “data\\projects\\a-project\\..\\..\\another-project”; Path path = Paths.get(originalPath); System.out.print(path.normalize()); What is the result? A. data\another-project B. data\projects\a-project\another-project C. data\\projects\\a-project\\..\\..\\another-project D. data\projects\a-project\..\..\another-project Correct Answer: D

Given: String originalPath = "data\\projects\\a-project\\..\\..\\another-project"; Path path = Paths.get(originalPath);

Given:String originalPath = “data\\projects\\a-project\\..\\..\\another-project”; Path path = Paths.get(originalPath); System.out.print(path.normalize()); What is the result? A. data\another-project B. data\projects\a-project\another-project C. data\\projects\\a-project\\..\\..\\another-project D. data\projects\a-project\..\..\another-project Correct Answer: D

public class StringReplace { public static void main(String[] args) { String message = "Hi everyone!";

public class StringReplace {public static void main(String[] args) {String message = “Hi everyone!”;System.out.println(“message = ” + message.replace(“e”, “X”)); }}What is the result? A. A runtime error is produced. B. message = C. message = Hi XvXryonX! D. message = Hi Xveryone! E. message = Hi everyone! F. A compile time error is produced. Correct Answer: C

Which two statements are correct regarding String and Integer property types?

Which two statements are correct regarding String and Integer property types? A. Both property types can include regular expressions. B. Both property types can contain alphanumeric characters and punctuation. C. Integer property types can be used for check box elements, whereas String property types can be used for phone numbers or email addresses. D. Both property types can… Read More »

An engineer creates an Ansible playbook to configure VRF information using a local_vrfs variable. The code must be completed so that it can be tested. Which string completes the code?

Refer to the exhibit. An engineer creates an Ansible playbook to configure VRF information using a local_vrfs variable. The code must be completed so that it can be tested. Which string completes the code? A. present B. up C. on D. active Answer: Option A. Explanation:  Reference: https://docs.ansible.com/ansible/latest/modules/ios_vrf_module.html Show AnswerDiscussion The post An engineer creates an Ansible playbook… Read More »