Practice Problems (Upto Interface)
Practice Problems (Upto Interface)
2.2.1 If statements.
2.2.2 Switch Statements.
2.2.3 For loop.
2.2.4 While Statements.
2.2.5 Do statements
2.4.1 To find the sum of command line arguments and count the
invalid integers entered.
2.4.2 To get the name using command line.
2.5 Write a program to print the following triangle of binary digits.
2.5.1 1 2.5.2 5
101 45
10001 345
1000001 2345
100000001 12345
012345
2.5.3 1
12
123
1234
12345
2.9.1 Addition.
2.9.2 Multiplication.
3.1 Write a program to create a room class, the attributes of this class is
roomno, roomtype, roomarea and ACmachine. In this class the member
functions are setdata and displaydata.
3.4 Write a program to give the example for ‘this’ operator. And also use the
‘this’ keyword as return statement.
4.2 Write a program for reuse class. For this program use the above ‘room
class’ program.
4.3 Create class named as ‘a’ and create a sub class ‘b’. Which is extends from
class ‘a’. And use these classes in ‘inherit’ class.
4.4 Write a program to give the example for method overriding concepts.
5.1 Write a program to create a class named shape. In this class we have three
sub classes circle, triangle and square each class has two member function
named draw () and erase (). Create these using polymorphism concepts.
6.3 Write a program to create interface named test. In this interface the
member function is square. Implement this interface in arithmetic class.
Create one new class called ToTestInt in this class use the object of
arithmetic class.
6.4 Create an outer class with a function display, again create another class
inside the outer class named inner with a function called display and call
the two functions in the main class.
7.1 Write a class called ColourChecking. Define a color with red = 193, green
=255 and blue = 183. No separate the rgb values. Find the Hue, saturation
and brightness of this color.
7.2 Write a program to check the font class method as follows: Create a font
TimesRoman bold and Italic size 12. In this object use the font methods.
Then display the attributes of the font.
7.3 Write a program to find the solution for the following problems using
Recursion.
7.3.2 Find the Fibonacci numbers are defined as F0=1,F1=1 and Fi=Fi-1+Fi-2
for i >2.