0% found this document useful (0 votes)
137 views

Finals For Data Structure

This document contains code for several Java programs that demonstrate working with arrays and arrays of multiple dimensions. It includes programs that initialize and populate single and multi-dimensional arrays, calculate averages and totals from array elements, sort array elements, and use stacks. It provides examples of basic array and stack operations in Java.

Uploaded by

Lianne Esco
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views

Finals For Data Structure

This document contains code for several Java programs that demonstrate working with arrays and arrays of multiple dimensions. It includes programs that initialize and populate single and multi-dimensional arrays, calculate averages and totals from array elements, sort array elements, and use stacks. It provides examples of basic array and stack operations in Java.

Uploaded by

Lianne Esco
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

package array1;

import java.io.*;

/**
*
* @author User
*/
public class Array1 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException{
// TODO code application logic here
BufferedReader DataIn=new BufferedReader(new InputStreamReader(System.in));
double []myList = {1.9,2.9,3.4,3.5};

//Print all the array elements


for(int i = 0; i <myList.length;i++){
System.out.println(myList[i]+"");

}
//Summing all elements
double total = 0;
for (int i=0;i<myList.length;i++){
total+=myList[i];
}
System.out.print("Total is" +total);
//Finding the largest element
double max=myList[0];
for (int i=1; i<myList.length;i++){
if (myList[i]>max)max=myList[i];
}
System.out.println("Msx is"+max);
}

}
public class Singlearray1 {

/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException{
// TODO code application logic here
BufferedReader DataIn=new BufferedReader(new InputStreamReader(System.in));
double []avg=new double[5];
double []prelim=new double[5];
double []midterm=new double[5];
double []Final=new double[5];

int x;
for(x=0;x<=2;x++){
System.out.print("enter prelim grade:");
prelim[x]=Double.parseDouble(DataIn.readLine());
System.out.print("enter midterm grade:");
midterm[x]=Double.parseDouble(DataIn.readLine());
System.out.print("enter final grade:");
Final[x]=Double.parseDouble(DataIn.readLine());

}
for(x=0;x<=2;x++){
avg[x]=(prelim[x]+midterm[x]+Final[x])/3;
}
for(x=0;x<=2;x++){
System.out.println("The Average:"+avg[x]);
}
}
package secondsem;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
*
* @author User
*/
public class Secondsem {

/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
BufferedReader DataIn=new BufferedReader (new InputStreamReader(System.in));
double grade[][][]=new double[3][3][2];
double id[]=new double[3];

double total[]=new double [3];


double total1[]=new double [3];

int R,C,A;

for(R=0; R<=2; R++){


System.out.print(" ID Number:");
id[R]=Double.parseDouble(DataIn.readLine());
for(C=0; C<=2; C++){
for (A=0; A<=1; A++){
System.out.print("Enter a grade:");
grade[R][C][A]=Double.parseDouble(DataIn.readLine());
}
}
}
for(R=0; R<=2; R++){

total [R]=(grade[R][0][0]+grade[R][1][0])/3;
}
for(R=0; R<=2; R++){

total1[R]=(grade[R][1][1]+grade[R][2][1])/3;
}
for (R=0; R<=2; R++){

total1[R]=(grade[R][1][1]+grade[R][2][1])/3;

for (R=0; R<=2; R++){


System.out.println("First Semester Average Grade:"+total[R]);
System.out.println("Second Semester Average Grade:"+total[R]);
}

}
}
}
package dimentionalarray;

/**
*
* @author User
*/
public class DimentionalArray {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

int arr[][][]= new int[3][4][2];


int i, j, k, num=1;

for(i=0; i<3; i++){


for(j=0; j<4; j++){
for(k=0; k<2; k++ ){

arr[i][j][k]= num;
num++;
}
}
}
for(i=0; i<3; i++){
for(j=0; j<4; j++){
for(k=0; k<2; k++){
System.out.println("arr [" +i+ "] [" +j+ "] [" +k+ "] +" +arr[i][j][k]+ "\t");
}
System.out.println();
}
System.out.println();
}
}
}

package base;

/**
*
* @author User
*/
public class Base {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
boolean flag = true;
char ch ='A';
byte b=12;
short s= 24;
int i=257;
long l=890L;//note the use of "L" here
float f = 3.1415F; //note the use of "F" here
double d=2.1828;
System.out.println("flag="+flag); //the "++ is string concatation
System.out.println("ch="+ch);
System.out.println("b="+b);
System.out.println("s="+s);
System.out.println("i="+i);
System.out.println("l="+l);
System.out.println("f="+f);
System.out.println("d="+d);
}
package sales;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author User
*/
public class Sales {

/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
BufferedReader DataIn=new BufferedReader (new InputStreamReader(System.in));
double[][]sale=new double [5][3];
double[] avg=new double [5];
double[] total=new double [5];
double tempavg,temptotal;
int R,C;
for (R=0; R<=4; R++){
for (C=0; C<=2; C++){
System.out.print("Enter A Sale:");
sale[R][C]=Integer.parseInt(DataIn.readLine());
}
}
for (R=0; R<=4; R++){
total[R]=sale[R][0]+sale[R][1]+sale[R][2];
}
for(R=0; R<=4; R++){
avg[R]=total[R]/3;
}
for(R=0; R<=3; R++){
for (C=R+1; C<=4; C++){
if(avg[R]<avg[C]){
if(total[R]<total[C]){
tempavg=avg[R];
avg[R]=avg[C];
avg[C]=tempavg;
temptotal=total[C];
total[R]=total[C];
total[C]=temptotal;
}
}
}
}
System.out.println("\tSALES\t\t"+"TOTAL\t\t"+"AVERAGE");
for(R=0; R<=4; R++){
System.out.println(sale[R][0]+" "+sale[R][1]+" "+sale[R][1]+" "+sale[R][2]+" "+total[R]+" "+avg[R]);
}
}
}
MIDTERM EXAM
package studentmid;
import java.io.*;
import java.util.Stack;
/**
*
* @author User
*/
public class StudentMid {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
BufferedReader DataIn=new BufferedReader (new InputStreamReader(System.in));
Stack<String> totalgrade= new Stack<>();
int count, i;
float totalGrade = 0, average,CurretnSatck=0;
int x;

System.out.println("Enter number of Subject:");


count = scanner.nextInt();

System.out.println("Enter grade of Subject");


for (i = 0; i < count; i++) {
System.out.println("Student_Name : " );
totalgrade.push(DataIn.readLine());
}
for(i=0;i< count;i++){
String gradeAtTop =totalgrade.pop();
System.out.println("Stack.pop() => " + gradeAtTop);
System.out.println("Current Stack => " + totalGrade);
float CurrentStack = totalGrade + totalGrade;
}
average = totalGrade / count;
System.out.println("Total_grade : " + totalGrade);
System.out.println("Prelim_Average : " + average);

}
}
package doublearray11;
import java.io.*;

* @author User
*/
public class Doublearray11 {
* @param args the command line arguments
*/
public static void main(String[] args)throws IOException {
// TODO code application logic here
BufferedReader DataIn = new BufferedReader (new InputStreamReader(System.in));
double[]avg=new double[5];
double[][]grade=new double[5][3];
int r,c;
for(r=0;r<=4;r++){
for(c=0;c<=1;c++){
System.out.print("Enter Student Grade:");
grade[r][c]=Double.parseDouble(DataIn.readLine());
}
}
for(r=0;r<=4;r++){
avg[r]=(grade[r][0]+grade[r][1]+grade[r][2])/3;
}
for(r=0;r<=4;r++){
System.out.println("Average:"+avg[r]);
}

}
package activity5.average;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author User
*/
public class Activity5Average {

/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args)throws IOException {
// TODO code application logic here
BufferedReader DataIn=new BufferedReader (new InputStreamReader(System.in));
double[] avg=new double [5];
double[][] sales=new double [5][3];
int S,A;

for (S=0; S<=4; S++){


for(A=0; A<=2; A++){

System.out.print("Enter sales:");
sales[S][A]=Double.parseDouble(DataIn.readLine());
}
}
for(S=0;S<=4;S++){
avg[S]=(sales[S][2]+sales[S][0]+sales[S][1])/3;
}
for(S=0;S<=4;S++){
System.out.println("Average:"+avg[S]);
}
}
package pkg3darray;
import java.io.*;
import java.util.Arrays;

/**
*
* @author User
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException{
// TODO code application logic here
BufferedReader girlie = new BufferedReader (new InputStreamReader(System.in));

int iArr[]={2,1,9,6,4};
for(int number:iArr){
System.out.println("Number="+number);

}
Arrays.sort(iArr);
System.out.println("The Sorted int array is: ");
for(int number: iArr){
System.out.println("Number ="+number);
}
}

}
package cards;
import java.io.*;
import java.util.Stack;

/**
*
* @author User
*/
public class Cards {

/**
* @param args the command line arguments
*/
public static void main(String[] args)throws IOException {
// TODO code application logic here
BufferedReader DataIn=new BufferedReader (new InputStreamReader(System.in));
//Creating a Stack
Stack<String> stackOfCards = new Stack<>();

//Pushing new items to the stack


stackOfCards.push("heart");
stackOfCards.push("diamond");
stackOfCards.push("ace");
stackOfCards.push("spade");
System.out.println("Stack=> " + stackOfCards);
System.out.println();

//Popping items form the Stack

String cardAtTop = stackOfCards.pop(); // Throws EmptyStackException if the stack is empty


System.out.println("Stack.pop() => " + cardAtTop);
System.out.println("Current Stack => " + stackOfCards);
System.out.println();

//get the item at the top of the stack without removing it


cardAtTop = stackOfCards.peek();
System.out.println("Stack.peek() => "+ cardAtTop);
System.out.println("Current Stack => " + stackOfCards);

}
package stacksizeexample;
import java.util.Stack;
import java.util.Scanner;
/**
*
* @author User
*/
public class Stacksizeexample {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int count, i;
float totalMarks = 0, percentage, average;
Scanner scanner;
scanner = new Scanner(System.in);

System.out.println("Enter number of Subject");


count = scanner.nextInt();

System.out.println("Enter Marks of " + count + " Subject");


for (i = 0; i < count; i++) {
totalMarks += scanner.nextInt();
}

average = totalMarks / count;


// Each subject is of 100 Marks
percentage = (totalMarks / (count * 100)) * 100;

System.out.println("Total Marks : " + totalMarks);


System.out.println("Average Marks : " + average);
System.out.println("Percentage : " + percentage);
}
}
}package mystack;

/**
*
* @author User
*/
public class MyStack {
private int maxSize;
private long[] stackArray;
private int top;

public MyStack(int s) {
maxSize = s;
stackArray = new long[maxSize];
top = -1;
}
public void push(long j) {
stackArray[++top] = j;
}
public long pop() {
return stackArray[top--];
}
public long peek() {
return stackArray[top];
}
public boolean isEmpty() {
return (top == -1);
}
public boolean isFull() {
return (top == maxSize - 1);
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
MyStack theStack = new MyStack(10);
theStack.push(10);
theStack.push(20);
theStack.push(30);
theStack.push(40);
theStack.push(50);

while (!theStack.isEmpty()) {
long value = theStack.pop();
System.out.print(value);
System.out.print(" ");
}
System.out.println("");
}
}
package stackproducts;
import java.io.*;
import java.util.Stack;
/**
*
* @author User
*/
public class Stackproducts {

/**
* @param args the command line arguments
*/
public static void main(String[] args)throws IOException {
// TODO code application logic here
BufferedReader DataIn=new BufferedReader (new InputStreamReader(System.in));
Stack<String> stackOfProducts = new Stack<>();
int x;
for(x=1;x<=10;x++){
System.out.println("Stack : " + stackOfProducts);
stackOfProducts.push(DataIn.readLine());

}
for(x=1;x<=10;x++){
String productAtTop = stackOfProducts.pop();
System.out.println("Stack.pop() => " + productAtTop);
System.out.println("Current Stack => " + stackOfProducts);
System.out.println();

}
}
package demo1;
import java.util.*;
public class Demo1 {
static void showpush(Stack stack1, int a) {
stack1.push(new Integer(a));
System.out.println("push(" + a + ")");
System.out.println("stack: " + stack1);
}
static void showpop(Stack stack1) {
Integer a = (Integer) stack1.pop();
System.out.println(a);
System.out.println("stack: " + stack1);
}
public static void main(String[] args) {
// TODO code application logic here
Stack stack1 = new Stack();
System.out.println("stack: " + stack1);
showpush(stack1, 40);
showpush(stack1, 50);
showpush(stack1, 60);
showpush (stack1, 70);
showpush (stack1, 80);
showpush (stack1, 90);
showpush (stack1, 100);
showpop(stack1);
showpop(stack1);
showpop(stack1);
showpop(stack1);
showpop(stack1);
showpop(stack1);
showpop(stack1);
try {
showpop(stack1);
} catch (EmptyStackException e) {
System.out.println("it Is Empty Stack");
}
}
}

package iteratoroverstackexam;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Stack;
/**
*
* @author User
*/
public class IteratorOverStackExam {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Stack<String> stackOfPlates = new Stack<>();

stackOfPlates.add("Plate 1");
stackOfPlates.add("Plate 2");
stackOfPlates.add("Plate 3");
stackOfPlates.add("Plate 4");

System.out.println("=== Iterate over a Stack using Java 8 forEach() method ===");


stackOfPlates.forEach(plate -> {
System.out.println(plate);
});

System.out.println("\n=== Iterate over a Stack using iterator() ===");


Iterator<String> platesIterator = stackOfPlates.iterator();
while (platesIterator.hasNext()) {
String plate = platesIterator.next();
System.out.println(plate);
}

System.out.println("\n=== Iterate over a Stack using iterator() and Java 8 forEachRemaining() method ===");
platesIterator = stackOfPlates.iterator();
while (platesIterator.hasNext()) {
String plate = platesIterator.next();
System.out.println(plate);
}

System.out.println("\n=== Iterate over a Stack from TOP to BOTTOM using listIterator() ===");
// ListIterator allows you to traverse in both forward and backward directions.
// We'll start from the top of the stack and traverse backwards.
ListIterator<String> platesListIterator = stackOfPlates.listIterator(stackOfPlates.size());
while (platesListIterator.hasPrevious()) {
String plate = platesListIterator.previous();
System.out.println(plate);
}
}
}
package utilarrays;
import java.util.Arrays;
import java.io.*;

/**
*
* @author User
*/
public class Utilarrays {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
BufferedReader DataIn=new BufferedReader (new InputStreamReader(System.in));
// TODO code application logic here

int r,c,a;
int sale[][][]=new int[3][5][3];
int first_total[]= new int[5];
int sec_total[]= new int[5];
int third_total[]= new int[5];

//input
for (r=0; r<=2; r++){
System.out.print("\n\n-----Arrays===Arrays===Arrays-----\n\n");
for (c=0; c<=4; c++){
System.out.print("***I love JAVA PROGRAMMING***\n");
for (a=0; a<=2; a++){
System.out.print("Enter the Sale: ");
sale[r][c][a]=Integer.parseInt(DataIn.readLine());
}
}
}

//proccess
for (c=0; c<=4; c++){
first_total[c]=(sale[0][c][0]+sale[1][c][0]+sale[2][c][0]);
}
for (c=0; c<=4; c++){
sec_total[c]=(sale[0][c][1]+sale[1][c][1]+sale[2][c][1]);
}
for (c=0; c<=4; c++){
third_total[c]=(sale[0][c][2]+sale[1][c][2]+sale[2][c][2]);
}

int iarr[]={first_total[0],first_total[1],first_total[2],first_total[3],first_total[4]};
System.out.println("\n***************(CBAA department)*************");
System.out.println("\nNot sorted:");
for (int number : iarr){
System.out.println("Total: " + number);
}

//sorting array
Arrays.sort(iarr);

//let us print all the elements available in list


System.out.println("\nThe sorted:");
for (int number:iarr){
System.out.println("Total: " + number);

int iarr1[]={sec_total[0],sec_total[1],sec_total[2],sec_total[3],sec_total[4]};
System.out.println("\n***************(CCJE department)*************");
System.out.println("\nNot sorted:");
for (int number1 : iarr1){
System.out.println("Total: " + number1);
}
//sorting array
Arrays.sort(iarr1);

//let us print all the elements available in list


System.out.println("\nThe sorted:");
for (int number1:iarr1){
System.out.println("Total: " + number1);

int iarr2[]={third_total[0],third_total[1],third_total[2],third_total[3],third_total[4]};
System.out.println("\n***************(ICS department)*************");
System.out.println("\nNot sorted:");
for (int number2 : iarr2){
System.out.println("Total: " + number2);
}

//sorting array
Arrays.sort(iarr2);

//let us print all the elements available in list


System.out.println("\nThe sorted:");
for (int number2:iarr2){
System.out.println("Total: " + number2);

}
}
}
package testcollection;
import java.util.LinkedList;
import java.util.Queue;
import java.util.PriorityQueue;
import java.util.Iterator;
/**
*
* @author User
*/
public class TestCollection {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
PriorityQueue<String>queue=new PriorityQueue<String>();
queue.add("Amit");
queue.add("Vijay");
queue.add("Karan");
queue.add("Jai");
queue.add("Rahul");
queue.add("Karan");
System.out.println("head:" + queue.element());
System.out.println("iterating the queue elements:");
Iterator itr=queue.iterator();

while(itr.hasNext()){
System.out.println(itr.next());
}
queue.remove();
queue.poll();
System.out.println("after removing two elements:");
Iterator<String>itr2=queue.iterator();
while(itr2.hasNext()){
System.out.println(itr2.next());
}

}
}
package queuegradessample;
import java.util.LinkedList;
import java.util.Queue;
import java.io.*;
/**
*
* @author User
*/
public class QueueGrades {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException{
// TODO code application logic here
BufferedReader gb=new BufferedReader(new InputStreamReader(System.in));
Queue<Integer> q = new LinkedList<>();
q.add(6);
q.add(1);
q.add(8);
q.add(4);
q.add(7);
System.out.println("The queue is: " + q);
int num1 = q.remove();
System.out.println("The element deleted from the head is: " + num1);
System.out.println("The queue after deletion is: " + q);
int head = q.peek();
System.out.println("The head of the queue is: " + head);
int size = q.size();
System.out.println("The size of the queue is: " + size);
}

package queuegrades;
import java.util.LinkedList;
import java.util.Queue;
import java.io.*;
/**
*
* @author User
*/
public class QueueGrades {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws
IOException{
// TODO code application logic here
BufferedReader gb=new BufferedReader
(new InputStreamReader(System.in));
Queue<Integer> q = new LinkedList<>();
int grades,i,avg,total=0;
for (i=1;i<=10;i++){
System.out.print("Enter Grades:");
grades=Integer.parseInt(gb.readLine());
q.add(grades);
if(i==10){
System.out.println("Grades:"+q);

}
}
for(i=1;i<=5;i++){
int num=q.remove();
System.out.println("Remove"+i+"values:"+num);
System.out.println("Remaining"+num);
}

}
}
class Emloyee{
int idnum;
String ename;
static String company="TNTS";

Employee(int id,String en){


idnum = id;
ename = en;

}
void display (){System.out.println(idnum+"\t"+ename+"\t"+company);}

public static void main (String args []){


Employee e1=new Employee (123, "Girlie");
Employee e2=new Employee (321, "Belino");

e1.display ();
e2.display ();
}
}
class emloyee2{
int idnum;
String ename;
static String company="TNTS";

static void change(){


company ="SMB";
}

employee2 (int idnum, String ename){


idnum = id;
ename = en;

}
void display (){System.out.println(idnum+" "+ename+" "+company);
}

public static void main (String args []){


employee2.change();

employee2 e1=new employee2 (123, "Girlie");


employee2 e2=new employee2 (321, "Padawag");
employee2 e3=new employee2 (234, "Belino");

e1.display ();
e2.display ();
e3.display ();
}
}
class employee3{
static{System.out.println("Static block is performed..");
}
public static void main (String args[]){
System.out.println("Completed!");
}
}
// ReportCard.java
//Class declaration with a method that has a parameter

public class ReportCard{


public void displayMessage (String gradeLevel)
{
System.out.printf("Welcome to the Report Card for \n%s!\n", gradeLevel);
}
}
//ReportCardTest.java
//create ReportCard object and pass a string to
// its displaymessage method

import java.util.Scanner;

public class ReportCardTest{


//main method begins program execution
public static void main (String args[])
{
Scanner input = new Scanner (System.in);
ReportCard myReportCard = new ReportCard();

System.out.println("Please enter the grade level:");


String levelofGrade = input.nextLine();//read a line text
System.out.println();//output a blank line

//call myReportCard'displaymessage method


//and pass levelofGrade as an argument
myReportCard.displayMessage(levelofGrade);
}
}
//Square.java
//Square method declarations.

public class Square


{
//test overloaded square methods
public void testSquares()
{
System.out.printf("Square of integer 9 is %d\n", Square (9));
System.out.printf("Square of double 9.5 is %f\n", Square (9.5));
}//end method testSquares

//square method with int argument


int Square(intintValue)
{
System.out.printf("\nCalled square with int argument:%d\n",intValue);
return intValue* intValue;

}//en method square with int argument

//square method with double argument


public double Square(double doubleValue)
{
System.out.printf("\ncalled square with double argument: %f\n", doubleValue);
return doubleValue * doublevalue;

}//end method square with double argument


}//end class square

//SquareTest.java
//Application to test class Square.

public class SquareTest


{
public static void main(String args [])
{
Square square= new Square();
Square.testSquares();
}//end main
}//end class SquareTest
//save as SampleDefaultA.java
package pack;
class SampleDefaultA
{
void msg(){System.out.println("Sikam Gayam!");}

}
//save as SampleDefaultB.java
package mypack;
import pack.*;
class SampleDefaultB{
public static void main (String args []){
SampleDefaultA obj = new SampleDefaultA();//Compile Time Error
obj.msg();//Compile Time Error
}

}
//sample as Sample_PublicA.java

package pack;
public class SamplePublicA{
public void msg(){System.out.println("Sikam Gayam");}

}
//save as SAmplePublicB.java

package mypack;
import pack.*;

class SamplePublicB{
public static void main(String args []){
SamplePublicA obj =new SamplePublicA();
obj.msg();
}
}
//save as SampleProtectedA.java
package pack;
public class SampleProtectedA{
protected void msg(){System.out.println("Sikam Gayam");}
}
//save by SampleProtectedB.java
package mypack;
import pack.*;

class SampleProtectedB extends SampleProtectedA{


public static void main ()String args []{
SampleProtectedB obj =new SampleProtectedB();
obj.msg();
}
}
//save as SamplePrivate.java
class X{
private int data=40;
private void msg(){System.out.printf("Sikam Gayam");}

}
public class SamplePrivate{
public static void main (String args[]){
X obj=new X();
System.out.println(obj.data);//Compile Time Error
obj.msg(); //Compile Time Error
}
}

You might also like