Follow

iklan banner
MASIGNCLEAN101

Core Java TYBBA (CA) Pratical Slip 20 Savitribai Phule Pune University

Core Java TYBBA (CA) Pratical Slip 20 Savitribai Phule Pune University
Mr PVK
December 13, 2022

 Slip 20


A) Write a java program using AWT to create a Frame with title “TYBBACA”, background color RED. If user clicks on close button then frame should close.

 

 import javax.swing.*;

import java.awt.*; 


class Slip20a{

    public static void main(String args[]) {


        JFrame frame = new JFrame("TYBBA CA");

        frame.setSize(400, 400);


        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        frame.getContentPane().setBackground(Color.RED);


        frame.setVisible(true);

    }

}



Program Output :









B) Construct a Linked List containing name: CPP, Java, Python and PHP. Then extend your java program to do the following: 

        i. Display the contents of the List using an Iterator 

        ii. Display the contents of the List in reverse order using a ListIterator


import java.util.*;

    public class Slip20b{

        public static void main (String args[]){

            LinkedList al = new LinkedList<>();


            al.add("CPP");

            al.add("JAVA");

            al.add("Python");

            al.add("PHP");


            System.out.println("Display content using Iterator...");


            Iterator il=al.iterator();

            while(il.hasNext()){

                System.out.println(il.next());

            }

            System.out.println("\nDisplay Content Revverse Using ListIterator");

            ListIterator li1=al.listIterator();


            while(li1.hasNext()){

                li1.next();

            }


            while(li1.hasPrevious()){

                System.out.println("" + li1.previous());

            }

        }

    }



Program Output: 


Display content using Iterator...

CPP

JAVA

Python

PHP


Display Content Revverse Using ListIterator

PHP

Python

JAVA

CPP



Share This :
Mr PVK
Write Your Response
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
-_-
(o)
[-(
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
(c)
cheer
(li)
(pl)