Java - Encapsulation



Question 2     

What can be implemented using encapsulation?






Question 3     

For which type of classes encapsulation is used?







Question 5     

Encapsulation is also called as?







Question 7     

Which among the following violates encapsulation always?







Question 9     

Which of the following lines error is occured

package pack;  //line 1
class A{  
  void msg(){
      System.out.println("Hello");
  }  
}  

package mypack;  
import pack.*;  //line 2
class B{  
    public static void main(String args[]){  
        A obj = new A();  //line 3
        obj.msg();  //line 4
    }  
}  






Question 10     

What is the output of the following code?

class A{  
    private int data=400;  
    private void msg(){
        System.out.println("Hello java");
    }  
}  
public class Simple{  
    public static void main(String args[]){  
        A obj=new A();  
        System.out.println(obj.data);
        obj.msg();
   }  
}  





Sign Up Page

Oops!!

To view the solution need to Login



Score : 0 / 0
L
o
a
d
i
n
g
.
.
.