Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer all 3 questions Consider the code set below. 3 public class Ex1_RunSetGet { 4- public static void main(String[] args) { 5 6 SetGet

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
please answer all 3 questions
Consider the code set below. 3 public class Ex1_RunSetGet { 4- public static void main(String[] args) { 5 6 SetGet sg = new SetGet("Samuel"); 7 8 System.out.println(sg.getName(); 9 } 10) 11 12 class SetGet { 13 14 private String name = "Kevin"; 15 16 SetGet(String name) { 17 18 1 19 20 public void setName(String n) { 21 namen 22 ) 23 24 25 26 27 ) What is the correct statement to be inserted in line 7 to change the value of the variable name on object sg to "Priya"? O sg.setName("Kevin", "Priya"); O setName("Priya"); sg.setName(String "Priya"); O sg.setName("Priya"); setName(String "Priya"); Consider the code set below. public class Exi_RunSetGet { public static void main(String[] args) { SetGet sg = new SetGet("Samue1"); 8 System.out.println(sg.getName(); 9 10 ) 11 12 class SetGet { 13 14 private String name = "Kevin": 15 16 SetGet(String name) { 17 18 } 19 public void setName(String n) { 22 namen 22 23 24 25 26 27 ) What is the correct implementation of a petter method for the variable calied name on the objects that could be inserted into the class SetGet on line 24-252 public String setName return name: 2e public void getName return name: 03 public String Betametname) return names public String cetName return this: 19 20 public void setName(String n) { 21 name = n; 22 } 23 24 25 26 27} What is the correct implementation of a getter method for the variable called name on the objects that could be inserted into the class SetGet on Wines 24-26 public String getName() { return name: 3 public voldgetName return name: 02 public String getName(name) O return name 3 public String getName O return this: > public String setName"Kevin return name: Consider the code set below. 3 public class Ex1_RunSetGet { public static void main(String[] args) { 5 6 SetGet sg = new SetGet("Samuel"); 7 8 System.out.println(sg-getName()); 9 } le) 11 12 class SetGet { 13 14 private String name = "Kevin"; 15 16 SetGet(String name) { 17 18 } 19 2e public void setName(String n) { 21 name = n; 22 } 23 24 25 26 27 ) What is the statement that should be added on line 15 to enable the statement on line 6 to instantiate a SetGet object where the value of the variable name is "Samuel name=this.name: O return name: this.name name: this name getNamethis

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago