0% found this document useful (0 votes)
8 views7 pages

Java Week - 3

The document contains snippets of Java code demonstrating various programming concepts. It includes a recursive method for calculating factorials, a class extending another class with multiplication and task methods, and a loop for counting digits in a number. Additionally, there are constructors and getter methods for a Student class, as well as a loop for finding divisors of a number.

Uploaded by

jns.pvt.lmtd
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views7 pages

Java Week - 3

The document contains snippets of Java code demonstrating various programming concepts. It includes a recursive method for calculating factorials, a class extending another class with multiplication and task methods, and a loop for counting digits in a number. Additionally, there are constructors and getter methods for a Student class, as well as a loop for finding divisors of a number.

Uploaded by

jns.pvt.lmtd
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Temp

Direct paste kar dena

.
1
public static int factorial(int x) {
if (x == 0 || x == 1) {
return 1;
} else {
return factorial(x - 1) * x;
}
}

.
class cls2 extends cls1 {

void mul(int a, int b) {


[Link](a * b);
}

void task(int a, int b) {


[Link](a * a + b * b);
}

}
.

int count = 0;

while (num != 0) {
count += 1;
num = num / 10;
}

[Link](count);
.
public Student(String name, int age) {
[Link] = name;
[Link] = age;
}

public String getName() {


return name;
}
public int getAge() {
return age;
}

for (int i = 1; i <= num; i++) {


if (num % i == 0) {
[Link](i + " ");
}
}

You might also like