Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Core%20Java%20Interview%20Questions%20and%20Answers

Question: Can you write a Java class that could be used both as an applet as well as an application?
Answer: Yes. Add a main() method to the applet.

import java.awt.*;
import java.applet.*;
import java.util.*;

public class AppApp extends Applet
{
	public void init()
	{
		add(new TextArea("Welcome to withoutbook.com"));
		String ar[]=new String[2];
		ar[0]="Welcome to withoutbook.com";
		main(ar);		
	} 
	
	public void main(String args[])
	{
		System.out.println(args[0]);
	}
}
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook