OOP Output

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1)

public class Q1{

int i;

private Q1(int i)

{ i=i;

public int getI()

return i;

public class Q2 extends Q1

int j;

public Q2(int i, int j)

super(i);

this.j=j;

public static void main(String [ ]arg)

{ Q2 q2=new Q2(5,4);

System.out.println(q2.getI());

Output_________________
2)

public abstract class Q3{

private int I;

public Q3(int i)

I=I;

public int getI()

return I;

public abstract String getClassName();

public class Q4 extends Q3{

int j;

public Q4(int i, int j)

super(i);

this.j=j;

public static void main(String []arg)

Q4 q4=new Q4(7,9);

System.out.println(q4.getI());

Output______________
3)

import java.util.ArrayList;

import java.util.Iterator;

public class Q5{

public static void main(String []arg)

ArrayList<Integer> arr1=new ArrayList<>();

for(int i=1; i<=10; i++)

arr1.add(i);

Iterator<Integer> it=arr1.iterator();

while(it.hasNext())

if((it.next())%2==0)

it.remove();

for(Integer a:arr1){

System.out.println(a);

Output_____________

You might also like