0% found this document useful (0 votes)
2 views4 pages

OutputTracing String Array

The document contains multiple Java class examples demonstrating various programming concepts such as string manipulation, array operations, and method usage. Each example includes a main method that creates an instance of the class and calls a specific method to showcase its functionality. Key operations include calculating sums, averages, and manipulating string values.

Uploaded by

zubeyerhassan
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)
2 views4 pages

OutputTracing String Array

The document contains multiple Java class examples demonstrating various programming concepts such as string manipulation, array operations, and method usage. Each example includes a main method that creates an instance of the class and calls a specific method to showcase its functionality. Key operations include calculating sums, averages, and manipulating string values.

Uploaded by

zubeyerhassan
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

Output Tracing:

Example 1:

class Search {
String word = "Software";
int[] arr = {10,20,30,40};
void process() {
[Link]( [Link]() );
int max = arr[0];
for(int i=1;i<[Link];i++) {
if(arr[i] > max)
max = arr[i];
} [Link](max);
}
}
public class Test {
public static void main(String[] args) {
Search s = new Search(); [Link]();
}
}

Example 2:
class Compare {
String s1 = "Java";
String s2 = "Java";
int[] arr = {10,20,30};
void check() {
[Link]([Link](s2));
int sum = 0;
for(int x : arr)
sum += x;
[Link](sum);
}
}
public class Test {
public static void main(String[] args) {
Compare c = new Compare(); [Link]();
}
}
Example 3:

class Box {
int len = 5;
String s1 = "Java";
String s2 = new String("Programming");
int[] arr = {10, 20, 30, 40};

void setLen(int len) { [Link] = len; }

void display() {
[Link]("Length = " + len);
[Link]([Link]());
[Link]([Link](3, 8));
arr[1] = arr[0] + ++arr[2];

for(int i = 0; i < [Link]; i++) {


[Link](arr[i] + " ");
}
[Link]();

double avg = (double)(arr[0]+arr[1]+arr[2]+arr[3])/[Link];

[Link](avg);
}

public static void main(String[] args) {

Box a = new Box();


[Link](++[Link]);
[Link]([Link]);
[Link]();
[Link]([Link]());
[Link]([Link]("g"));
[Link](--[Link]);
}
}
Example 4:
class Test {
int num = 8;
String str1 = "Database";
String str2 = new String("System");
int[] data = {2, 4, 6, 8};

void setNum(int n) { num = n; }

void process() {
[Link]([Link](2));
[Link]([Link]());
data[0] = ++data[1] + data[2]--;

for(int x : data)
[Link](x + " ");

[Link]();
[Link](data[2]);
}

public static void main(String[] args) {

Test t = new Test();


[Link]([Link]++);
[Link]([Link]);
[Link]();
[Link]([Link](4));
[Link](++[Link]);
[Link]([Link]());
}
}
Example 5:

class Student {
String name;
int[] marks;

Student(String n, int[] m) {
name = n;
marks = m;
}

void display() {

[Link]([Link]());
[Link]([Link](1,4));

int total = 0;

for(int i=0;i<[Link];i++) {
total += marks[i];
}

[Link](total);

double avg = (double)total/[Link];


[Link](avg);
}
}

public class Test {


public static void main(String[] args) {

int[] a = {70,80,90};

Student s = new Student("Rahim",a);

[Link]();
}
}

You might also like