Class-and-object

Question 1
What is the output of the following JAVA program ?
Class Test {
   public static void main(String[] args) {
       Test obj = new Test();
       obj.start();
   }
   void start() {
       String stra = ”do”;
           String strb = method(stra);
       System.out.print(“: ”+stra + strb);
   }
   String method(String stra) {
       stra = stra + ”good”;
       System.out.print(stra);
       return“ good”;
   }
}
A
dogood : dogoodgood
B
dogood : gooddogood
C
dogood : dodogood
D
dogood : dogood
Question 2
The memory occupied by an object type of data in VB is
A
1 byte
B
2 byte
C
4 byte
D
8 byte
Question 2 Explanation: 

Question 3
If a class C is derived from class B, which is derived from class A, all through public inheritance, then a class C member function can access
A
Protected and public data only in C and B
B
Protected and public data only in C
C
Private data in A and B
D
Protected data in A and B
Question 3 Explanation: 
The following table shows the access to members permitted by each modifier.
Question 4
Members of  class by default are
A
Public
B
Private
C
Protected
D
Mandatory to specify
Question 4 Explanation: 
→A class in C++ is a user defined type or data structure declared with keyword class that has data and functions (also called methods) as its members whose access is governed by the three access specifiers private, protected or public (by default access to members of a class is private).
→The private members are not accessible outside the class; they can be accessed only through methods of the class. The public members form an interface to the class and are accessible outside the class.
There are 4 questions to complete.

Access quiz wise question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

Register Now

If you have registered and made your payment please contact solutionsadda.in@gmail.com to get access