Tai assignments Flashcards

1
Q

Create a class and instantiate it

A

class Student{
int rollno;
int age;
String name;
int grade;
char section;
String subjects[];
void displayDetails(){
System.out.println(“Roll no: “+rollno);
System.out.println(“Age: “+age);
System.out.println(“name: “+name);
System.out.println(“section: “+section);
System.out.println(“grade: “+grade);
for(String subject:subjects){
System.out.println(subject);
}
}

}
class Main{
public static void main(String[] args){
Student Student1 = new Student();

Student1.age = 12;
Student1.rollno = 23;
Student1.grade = 8;
Student1.section = ‘D’;
Student1.name = “Vaishnavi”;
Student1.subjects = new String[]{“math”, “Hindi”, “English”};
Student1.displayDetails();

}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Garbage Collection in Java

A

Garbage Collection in Java

Garbage collection is a mechanism in Java that automatically frees up memory occupied by objects that are no longer needed or referenced. This process is performed by the Java Virtual Machine (JVM) to prevent memory leaks and ensure efficient use of system resources. The JVM periodically identifies objects that are no longer in use and reclaims their memory, making it available for new object allocations. Garbage collection is a crucial aspect of Java programming, as it eliminates the need for manual memory management and reduces the risk of memory-related errors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

create an interface

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

using recursion write code to find factorial of a number

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

access modifiers accessed using getters and setters

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

return object

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Static variable static method and static block ? can static variable be access by non static method and why?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is the use of static method

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly