DBMS Lecture Notes Itt206
DBMS Lecture Notes Itt206
DBMS Lecture Notes Itt206
PRINCIPLES OF OBJECT
ORIENTED
TECHNIQUES
Ms Vrinda A
Assistant Professor,
Dept. of IT, MESCE,
Kuttippuram
Text Book
In OOPs access
Access modifiers are introduced On other hand no such
modifiers namely as Private, modifiers are introduced in
Public, and Protected POP.
(b)
Sequence Structure
if Selection
Statement
if (grade >= 60 )
System.out.println( “Passed" );
if -else Selection
Statement
if ( grade >= 60 )
System.out.println(“Passed");
else
System.out.println(“Failed");
Question
Write a program to check a given number is negative or
not.
Write a program to check whether the given number is
odd number or even number.
Write a program to find the largest of two numbers.
Write a program to find the largest of three numbers.
Nested if…
if ( grade else
>=
90 System.out.println(
) "A" );
else if ( grade >= 80 )
System.out.println( "B" );
else if ( grade >= 70 )
System.out.println( "C" );
else if ( grade >= 60 )
System.out.println( "D" );
else
System.out.println( "F" );
Questions
Write a menu-driven program to perform the different
mathematical operations.
int count = 1;
while ( count <= 100 )
{
System.out.println(count);
}
Repetition Statement while
int i = 1, sum =
0; while ( i <=
100 )
{
sum = sum +
i; i = i +
1;
}
Repetition Statement for
do
{
.....
.....
}while(condition);
Questions
Write a program to find the sum of squares of first 10
numbers.
Write a program to print all the even numbers between
two limits.
Write a program to find the factorial of a number.
break and continue Statement
The break causes immediate exit from the loop statements.
Execution continues with the first statement
after the structure.
class Test {
public static void main(String[] args) {
// for loop
for (int i = 1; i <= 10; i++) {
// if the value of i is 5 the loop terminates
if (i == 5) {
break;
}
System.out.println(i);
}
}}
break and continue Statement
The continue statement skips the remaining statements
in the body of the statement and proceeds with the next
iteration of the loop.
void pay ()
{
System.out.println("Pay
to the Employee " +
name + " $" +
salary);
}
}
How to declare and create objects?
Benefits of Garbage
Collection
• It automatically handles the deletion of unused or
unreachable objects to free up memory resources.
• Programmers working in languages without garbage
collection (like C and C++) must implement manual
memory management in their code.