ICSE Board Computer Application Syllabus (2012-2013)
[1] Elementary Concept of Objects and Classes, [2] Values and types, [3] Conditionals and non-nested loops, [4] Class as the Basis of all Computation, [5] Constructors, [6] Functions, [7] Class as a User Defined Type, [8] Iterations, [9] Using Library Classes, [10] Encapsulation, [11] Arrays, [12] Input/Output.

Sunday, October 9, 2011

Class as a User Defined Types

Q. What is data type?
Ans: Data types are means to identify the type of data and associated operations of handling it.
Q. What is composite (user define) data type? Explain with an example? [2007] [2009]
Ans: A composite datatype is that datatype that are based on fundamental or primitive datatypes. A 'class' is an example of composite datatypes.class Date{  int dd, mm, yy;  public Date()  {    dd=1;    mm=1;    yy=2005;  }}
Q. What is user define datatype?
Ans: A user defined datatype is a data type that is not a part of the language and is created by a programmer.
Q. Can you refer to a class as a user defined (composite) data type? [2009]
Ans: Yes, we can refer to a class not having a main() method as user-defined data type.
Q. What is the difference between primitive data types and composite data types?
Ans: (i) primitive data types are built-in data types. Java provides these data types. User-defined data types are created by users. (ii) The size of primitive data types are fixed. The size of user-defined data types are variable. (iii) Primitive data types are available in all parts of Java programs. The availability of user-defined data types depends upon their scope.
Q. Compare a class as a user defined data type and class as an application?
Ans: In Java, all functionality is enclosed in classes. But in order for a class to be user-defined data type, it should be act different from that of an application. i.e. it should not include main() method in it. Although we can create instance of classes containing main method, they should not be referred to as used-defined data type. Such classes (containing main() method) are more analogues to application than a data type.
Q. How are private member different from public member of a class.
Ans: Private members of a class are accessible in the member function of the class only, where as public members are accessible globally.
Q. How are protected members different from public and private members of a class.
Ans: Protected members of a class are accessible in all the classes in the same package and subclass in the other packages. private members of a class accessible in the member functions in the class only. Where as public members are accessible globally.
Q. Mention any two attributes required for class declaration. [2008]
Ans: The two attributes for class declaration are: 1. Access Specifier  2. Modifier 3. Class Name

No comments:

Post a Comment