OOP Using Java Assignment 1 CMPLT
OOP Using Java Assignment 1 CMPLT
Assignment 1
Q No Question
1 Write a program to find the sum of all integers greater than 40 and less than 250
that are divisible by 5.
ANSWER 1.
class abc
int sum=0;
for(int i=40;i<251;i++){
if(i%5==0 ){
System.out.println(i);
sum=sum+i;
}
System.out.println("the sum of intergers from 40 to 250 that are divisible
by 5 \n" + sum);
ANSWER 2.
this.name = name;
this.id = id;
this.marks = marks;
return "Student Name: " + name + "\nSAP Id: " + id + "\nMarks: " +
marks;
System.out.println(student.getData());
ANSWER 3.
Early binding or static polymorphism are other names for compile time
polymorphism in Java. Compile time polymorphism gets its name from the fact
that the binding is done at the time of compilation. Connecting the function call
and the function body is referred to as binding. It is accomplished via
overloading operators and methods as well as by modifying the function’s
signature. The class’s reference variable handles the overloading of methods.
By adding additional features to an operator, operator overloading is
accomplished. The return value and its type, as well as the parameters and their
types, are referred to as the function’s signature. It outlines a function’s input
and output.
class SimpleCalculator
return a+b;
}
int add(int a, int b, int c)
return a+b+c;
System.out.println(obj.add(10, 20));