Skip to main content

Posts

Sri Aurobindo Public School, Baddi CLASS XII: Test-1 Topic : Class and Objects/Constructor and destructor 1.  Write   the output of the following C++ program code                                      3 Note  :  Assume all required header   files are already being    included in the program. class   Eval { Char   Level; int Point; public: Eval(){Level=’E’;Point=0;} void Sink(int L) {   Level-   =L;   } void Float(int L) {    Level+=L   ; Point++;    } void   Show() {   cout<<Level<<”#”<<Point<<endl;  ...

CLASS and OBJECTS

CLASS and OBJECTS 1.Give the output of the following program ( Assuming that all required header files are  included in the program )     :                class TEMP { static int a; float b; public: TEMP( ) { b=10; } void INTEMP( ) { a++; b=a+10; } void OUTTEMP( ) { cout<<a*i<<"$"<<b-3<<endl; } }; int TEMP::a=2; void main() { TEMP ob[5]; for(int x=1;x<5;x++) ob[x].INTEMP( ); for(x=1;x<5;x++) ob[x].OUTTEMP( );}  2.  Define a class Travel in C++ with the description given below: Private Members: T_Code of type string No_of_Adults of type integer No_of_Children of type integer Distance of type integer TotalFare of type float Public Members: A constructor to assign initial values as follows : T_Code with the word “NULL” No_of_Adults as 0 No_of_Children as 0 Distance as 0 TotalFare as 0 A func...
1. //WAP in java to print "HAPPY BIRTHDAY" message ten times on the screen. class l1 { public static void main(String args[]) { int i; for(i=0;i<10;i++) System.out.println("HAPPY BIRTHDAY"); } } 2. //WAP in java to print the alternate week day names.Do not input the week day number. class l2 { public static void main(String args[]) { int i; for(i=0;i<10;i++) { if(i==1) System.out.println("Sunday"); else if(i= =3) System.out.println("Tuesday"); else if(i= =5) System.out.println("Thursday"); else if(i= =7) System.out.println("Saturday"); } } } 3. //WAP in java to print first 100 even number class l3 { public static void main(String args[]) { int i; for(i=0;i<100;i+=2) System.out.println(i); } } 4. //WAP in java to print all positive odd numbers upto 155 class l4 { public static void main(String args[])...