Question

Question 19 Given the following class: public class Swapper ( private int x; private String y public int z; public Swapper( i
Select all of the reasons to use encapsulation with classes. Helps ensure data integrity by forcing the use of public member
0 0
Add a comment Improve this question Transcribed image text
Answer #1
Question 19:
no

Question 20:
True

Question 21:
Options 1, 4

Question 22:
Option 3
Add a comment
Know the answer?
Add Answer to:
Question 19 Given the following class: public class Swapper ( private int x; private String y...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • output What is the output of the following: class Access public int x; private int y...

    output What is the output of the following: class Access public int x; private int y public void cal(int x, int y) { this.x = x + 1; this.y = y; } public void print() { System.out.print(""+y); } } class AccessSpecifier { public static void main(String args[]) { Access obj = new Access(); obj.cal(2, 3); System.out.print(obj.x); obj.print(); } } 33 Compilation error 23 None of the available choices Runtime error

  • Java Inner class class Outer {    private int x=10;    private static int y=20 ;...

    Java Inner class class Outer {    private int x=10;    private static int y=20 ;    publics void M1( ) {          int z=30;        class Inner           {             public void M2()              {                                                                              Sytem.out.println(“sum: ”+ (x+y+z));               }         } Inner i=new Inner();    i.M2() ; /// first call    i.M2(); // second call i.M2(); // third call }   // end of M1        publics static void main(String[] args)       {           Outer O = new...

  • For Questions 1-3: consider the following code: public class A { private int number; protected String...

    For Questions 1-3: consider the following code: public class A { private int number; protected String name; public double price; public A() { System.out.println(“A() called”); } private void foo1() { System.out.println(“A version of foo1() called”); } protected int foo2() { Sysem.out.println(“A version of foo2() called); return number; } public String foo3() { System.out.println(“A version of foo3() called”); Return “Hi”; } }//end class A public class B extends A { private char service; public B() {    super();    System.out.println(“B() called”);...

  • For Questions 1-3: consider the following code: public class A { private int number; protected String...

    For Questions 1-3: consider the following code: public class A { private int number; protected String name; public double price; public A() { System.out.println(“A() called”); } private void foo1() { System.out.println(“A version of foo1() called”); } protected int foo2() { Sysem.out.println(“A version of foo2() called); return number; } public String foo3() { System.out.println(“A version of foo3() called”); Return “Hi”; } }//end class A public class B extends A { private char service; public B() {   super();   System.out.println(“B() called”); } public...

  • public class Animal {    private String name; //line 1    private int weight; //line 2...

    public class Animal {    private String name; //line 1    private int weight; //line 2    private String getName(){       return name;    } //line 3    public int fetchWeight(){       return weight; } //line 4 } public class Dog extends Animal {    private String food; //line 5    public void mystery(){       //System.out.println("Name = " + name); //line 6            System.out.println("Food = " + food); //line 7    } } I want to know the super...

  • Here is the code for the Infant class: public class Infant{ private String name; private int...

    Here is the code for the Infant class: public class Infant{ private String name; private int age; // in months public Infant(String who, int months){ name = who; age = months; } public String getName(){ return name;} public int getAge(){ return age;} public void anotherMonth() {age = age + 1;} } The code box below includes a live Infant array variable, thoseKids. You cannot see its declaration or initialization. Your job is to find out which Infant in the array...

  • skeleton: import java.util.*; public class Point3D{ private int x,y,z; Point3D(int a, int b, int c){ x = a; y = b; z = c; } public int x(){ return x; } public int y(){ return y; } public in...

    skeleton: import java.util.*; public class Point3D{ private int x,y,z; Point3D(int a, int b, int c){ x = a; y = b; z = c; } public int x(){ return x; } public int y(){ return y; } public int z(){ return z; } public String toString(){ return "("+x+","+y+","+z+")"; } } Question1Test.java import java.util.*; public class Question1Test { public static void main(String[] args){ MyHashList<Point3D> lst = new MyHashList<Point3D>(1000); } } a) A class Point3D is given. Re-write this class so that...

  • Examine the following class definition: public class Date private int year; private int month; private int...

    Examine the following class definition: public class Date private int year; private int month; private int day; public Date() { ...) public void set (int x, int y, int z) { ...) public int getYear() { ...) // returns year public int getMonth() { } // returns month public int get Day () { ...) // returns day //more methods here -- 1 Which of the following statements in a client program correctly prints out the day of the object...

  • Given the following class: class Q2 { private int a; private int b; private int c;...

    Given the following class: class Q2 { private int a; private int b; private int c; public void setA(int a){this.a = a; } public void setB(int b){this.b = b;} public void setc(int c){this.c = c;} public int geta(){return a; } public int gets(){return b;} public int getc(){return c;} public int m1(int a, int b){ return a + b; public boolean m2 (int x, int y){ return m1(x, y) + x + y < 10; What is the output of the...

  • What is wrong with the following code: class Point { private : int x, y; public...

    What is wrong with the following code: class Point { private : int x, y; public : Point (int u, int v) : x(u), y(v) {} int getX () { return x; } int getY () { return y; } void setX (int newX ) const { x = newX ; } }; int main () { Point p(5, 3); p.setX (9001) ; cout << p. getX () << ’ ’ << p. getY (); return 0; }

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT