• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inner class

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1 import java.applet.Applet;
2 import java.awt.*;
3 import java.awt.event.*;
4 public class hello4 extends Applet {
5 public void init(){
6 add(new myButton("BBB"));
7 }
8 public void paint(Graphics screen) {
9 }
10 class myButton extends Button{
11 myButton(String label){
12 super(label);
13 }
14 public String paramString(){
15 return super.paramString();
16 }
17 }
18 public static void main(String[] args){
19 Frame myFrame = new Frame(
20 "Copyright Amit");
21 myFrame.setSize(300,100);
22 Applet myApplet = new hello4();
23 Button b = new Button("My Button");
24 myApplet.add(b);
25 b.setLabel(b.getLabel()+"New");
26 // myButton b1 =(new hello4()).new myButton("PARAMBUTTON");
27 System.out.println(b1.paramString());
28 myFrame.add(myApplet);
29 myFrame.setVisible(true);
30 myFrame.addWindowListener(new WindowAdapter(){
31 public void windowClosing(WindowEvent e){
32 System.exit(0);}});
33 }
34 } //End hello4 class.
Q4 In the code if you compile as "javac hello4.java" following files will be generated.
a) hello4.class, myButton.class,hello41.class
b)hello4.class, hello4$myButton.class,hello4$1.class
c)hello4.clas,hello4$myButton.class
Correct answer is b)
In b) hello4$1.class represents which class???For which class
is it created.
thanks!
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is for the annonymous class declared in line 30
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic