File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Mock test doubt? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Mock test doubt?" Watch "Mock test doubt?" New topic

Mock test doubt?

swati cha
Ranch Hand

Joined: Jul 04, 2006
Posts: 40
Hi all,

can anyone explain the following code output....

import java.awt.*;
import java.awt.event.*;
public class MyWc extends Frame implements WindowListener{
public static void main(String argv[]){
MyWc mwc = new MyWc();
public void windowClosing(WindowEvent we){
}//End of windowClosing
public void MyWc(){
}}//End of class

Mack Stevens

Joined: Aug 31, 2007
Posts: 17
When you are implementing WindowListener in your code you need to override all the abstract methods of WindowListener ,else you need to declare your class as abstract.
Alternative solution is to use extend WindowAdapter class which provides empty declarations for the abstract methods in WindowListener.
swati cha
Ranch Hand

Joined: Jul 04, 2006
Posts: 40
can we declare the main class as abstract?
madhu kancharla

Joined: Jul 30, 2007
Posts: 14
hi swati

you can not declare main as abstract,
main is the starting point for the JVM to start execution of your program if
its abstract it wont even compile because definitely you will write block of code for that.
but remember abstract methods dont have method body
in fact main is the static method
dont make any static method as abstract its compiler error

hope its clear
swati cha
Ranch Hand

Joined: Jul 04, 2006
Posts: 40
Thanks for your reply
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Howdy "swati" !

Thanks for one of your first contributions to this forum and...

Welcome to the Ranch!

Hope you'll enjoy.

Only one small issue: The Java Ranch follows a certain policy regarding user names.
The main reasons why and a link how to change yours you'll find here:

So, could you please change your user name before your next posting?
It will not affect anything you've already posted here. Just your user name will update.

I'm posting this because I am one of the moderators of this forum.


all events occur in real time
Mack Stevens

Joined: Aug 31, 2007
Posts: 17
No you cant declare main as abstract
Provide two classes for your application,one(having main method)extending Frame and other class extending WindowAdapter,because you cant extend two classes.
I agree. Here's the link:
subject: Mock test doubt?
It's not a secret anymore!