Question: public class Anotherclass private static int val =31; private String data; public Anotherclass ( String s) f. data =7 val f=2 : public void join(String
public class Anotherclass private static int val =31; private String data; public Anotherclass ( String s) f. data =7 val f=2 : public void join(String s) ( data = data +5; ) public void set.Datia (String s) ( data = 87 ) public string getData() \{ return data; \} public int getval() ( return val; ? 1 9. The following code segment appears in the main method of another class. Anotherclass word = new AnotherClass ( Hel1o"); word. joint "Hel1o"): Anotherclass sentence = new Anotherclass(word. getData()); sentence. join( "Hi*); word.setDatafentence. getData()): word. join ( "Hel1o"): sentence. joint " Hi.) sentence. setData( Hi ) ; System. out.println(word. getVal()); What is printed as a restult of executing the code segnent? (A) 30 (B) 15 (C) 7.75 (D) 7.5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
