importantanswers
importantanswers
importantanswers
1. OOPS CONCEPT:
• Object
• Class
• Inheritance
• Polymorphism
• Abstraction
• Encapsulation
OBJECT:
Object means a real word entity such as pen, chair, table etc. Any entity that has state and
behaviour is known as an object. Object can be defined as an instance of a class.
CLASS:
A class can also be defined as a blueprint from which you can create an individual object
INHERITANCE:
Inheritance can be defined as the procedure or mechanism of acquiring all the properties and
behaviour of one class to another, i.e., acquiring the properties and behaviour of child class
from the parent class.
POLYMORPHISM:
When one task is performed by different ways i.e. known as polymorphism. For example: to
convince the customer differently, to draw something e.g. shape or rectangle etc.
Polymorphism is classified into two ways:
Method Overloading (Compile time Polymorphism)
Method Overloading is a feature that allows a class to have two or more methods having the
same name but the arguments passed to the methods are different.
Method Overriding (Run time Polymorphism) If subclass (child class) has the same method as
declared in the parent class, it is known as method overriding in java
ABSTRACTION:
Abstraction is a process of hiding the implementation details and showing only functionality
to the user.
ENCAPSULATION:
Encapsulation in java is a process of wrapping code and data together into a single unit, for
example capsule i.e. mixed of several medicines. A java class is the example of encapsulation
1
2. CONSTRUCTOR
Constructors are special member functions whose task is to initialize the objects of its
class. It is a special member function, it has the same as the class name. Java
constructors are invoked when their objects are created. It is named such because, it
constructs the value, that is provides data for the object and are used to initialize objects.
The constructor in Java cannot be abstract, static, final or synchronized and these
modifiers are not allowed for the constructor.
There are two types of constructors:
1. Default constructor (no-arg constructor)
2. Parameterized constructor
Default constructor (no-arg constructor)
A constructor having no parameter is known as default constructor and no-arg constructor
Program:
class Box
{
int width;
int height;
int depth;
// This is the constructor for Box.
Box()
{
width = 10;
height = 10;
depth = 10;
}
void volume()
{
System.out.println(width * height * depth);
}}
class demo
{
public static void main(String args[])
{
Box mybox1 = new Box();
2
mybox1.volume();
}}
Output:
1000
Parameterized Constructors
A constructor which has a specific number of parameters is called parameterized constructor.
Parameterized constructor is used to provide different values to the distinct objects
Program:
class Box
{
int width;
int height;
int depth;
// This is the constructor for Box.
Box(int w, int h, int d)
{
width = w;
height = h;
depth = d;
}
void volume()
{
System.out.println(width * height * depth);
}}
class demo
{
public static void main(String args[])
{
Box mybox1 = new Box(10,10,10);
mybox1.volume();
}}
Output:
1000
3
3. THIS KEYWORD
this keyword is used to to refer to the object that invoked it. this can be used inside any
method to refer to the current object. That is, this is always a reference to the object on
which the method was invoked. this() can be used to invoke current class constructor.
Program:
class Box
{
int width;
int height;
int depth;
// This is the constructor for Box.
Box(int w, int h, int d)
{
this. width = w;
this. height = h;
this. depth = d;
}
void volume()
{
System.out.println(width * height * depth);
}}
class demo
{
public static void main(String args[])
{
Box mybox1 = new Box(10,10,10);
mybox1.volume();
Box mybox2=new Box(10,20,30);
Mybox2.volume();
}}
Output:
1000
6000
4
4. ACCESS SPECIFIERS
The access modifiers in java specifies accessibility (scope) of a data member, method,
constructor or class. There are 4 types of java access modifiers: 1. private 2. default 3.
protected 4. Public
5. Selection Statements in Java
A programming language uses control statements to control the flow of execution of
program based on certain conditions.
Java’s Selection statements:
if
if-else
nested-if
if-else-if
switch-case
jump – break, continue, return
if Statement
if statement is the most simple decision making statement. It is used to decide whether
a certain statement or block of statements will be executed or not that is if a certain
condition is true then a block of statement is executed otherwise not.
Syntax:
if(condition)
{
//statements to execute if
//condition is true
}
Program:
Class demo
{
public static void main(String args[])
{
int a=10;
if(a>0)
{
System.out.println(“a is positive”);
5
}
}}
if-else Statement
The Java if-else statement also tests the condition. It executes the if block if condition is true
else if it is false the else block is executed.
Syntax:
if(condition)
{ //Executes this block if //condition is true
}
else
{ //Executes this block if //condition is false
}
Program:
Class demo
{
public static void main(String args[])
{
int a=10;
if(a>0)
{
System.out.println(“a is positive”);
}
else
System.out.println(“a is negative”);
}}
if-else-if statement
The if statements are executed from the top down. The conditions controlling the if is true, the
statement associated with that if is executed, and the rest of the ladder is bypassed. If none of
the conditions is true, then the final else statement will be executed.
Syntax:
if(condition)
statement;
else if(condition)
statement;
6
else if(condition)
statement;
...
else statement;
Program:
Class demo
{
public static void main(String args[])
{
int a=10;
if(a>0)
{
System.out.println(“a is positive”);
}
else if (a<0)
{
System.out.println(“a is negative”);
}
else
System.out.println(“ a is equal to zero”);
}}
6. ITERATIVE STATEMENTS
In programming languages, loops are used to execute a set of instructions/functions
repeatedly when some conditions become true. There are three types of loops in java.
while loop
do-while loop
for loop
while loop
A while loop is a control flow statement that allows code to be executed repeatedly
based on a given Boolean condition. The while loop can be thought of as a repeating if
statement.
Syntax:
while(condition)
{
7
// body of loop
}
Program:
class demo
{
public static void main(String args[])
{
int n = 1;
while(n < 5)
{
System.out.println(n);
n++;
}}}
do-while loop:
do while loop checks for condition after executing the statements, and therefore it is
called as Exit Controlled Loop.
Syntax:
do
{
// body of loop
}
while (condition);
Program:
class demo
{
public static void main(String args[])
{
int n = 1;
do
{
System.out.println(n);
n++;
}
while(n<5)
8
}}
For loop
for loop provides a concise way of writing the loop structure. A for statement consumes
the initialization, condition and increment/decrement in one line.
Syntax
for(initialization; condition; iteration)
{
// body
}
Program:
class demo
{
public static void main(String args[])
{
for(int n=1;n<5;i++)
{
System.out.println(n);
}
}}
7. INHERITANCE
Inheritance can be defined as the procedure or mechanism of acquiring all the properties
and behaviours of one class to another, i.e., acquiring the properties and behavior of
child class from the parent class.
Uses of inheritance in java
• For Method Overriding (so runtime polymorphism can be achieved).
• For Code Reusability.
Types of inheritance in java: single, multilevel and hierarchical inheritance. Multiple
and hybrid inheritance is supported through interface only.
Syntax:
class subClass extends superClass
{
//methods and fields
}
9
SINGLE INHERITANCE
In Single Inheritance one class extends another class (one class only).
Example:
public class ClassA
{
public void displayA()
{
System.out.println("disp() method of ClassA");
}}
public class ClassB extends ClassA
{
public void displayB()
{
System.out.println("disp() method of ClassB");
}
public static void main(String args[])
{
ClassB b = new ClassB();
10
b.displayA();
b.displayB();
}}
MULTILEVEL INHERITANCE
In Multilevel Inheritance, one class can inherit from a derived class. Hence, the derived class
becomes the base class for the new class.
Example:
public class ClassA
{
public void dispA()
{
System.out.println("disp() method of ClassA");
}}
public class ClassB extends ClassA
{
public void dispB()
{
System.out.println("disp() method of ClassB");
}}
public class ClassC extends ClassB
{
public void dispC()
{
System.out.println("disp() method of ClassC");
}
public static void main(String args[])
{
ClassC c = new ClassC();
c.dispA();
c.dispB();
c.dispC();
}}
HIERARCHICAL INHERITANCE
In Hierarchical Inheritance, one class is inherited by many sub classes.
11
Example:
public class ClassA
{
public void dispA()
{
System.out.println("disp() method of ClassA");
}}
public class ClassB extends ClassA
{
public void dispB()
{
System.out.println("disp() method of ClassB");
}}
public class ClassC extends ClassA
{
public void dispC()
{
System.out.println("disp() method of ClassC");
}
public static void main(String args[])
{
ClassC c = new ClassC();
c.dispA();
c.dispC();
ClassB b = new ClassB();
b.dispA();
b.dispB();
}}
Hybrid Inheritance is the combination of both Single and Multiple Inheritance. Again Hybrid
inheritance is also not directly supported in Java only through interface we can achieve this.
Flow diagram of the Hybrid inheritance will look like below. As you can ClassA will be acting
12
as the Parent class for ClassB & ClassC and ClassB & ClassC will be acting as Parent for
ClassD.
Multiple Inheritance is nothing but one class extending more than one class. Multiple
Inheritance is basically not supported by many Object Oriented Programming languages such
as Java, Small Talk, C# etc.. (C++ Supports Multiple Inheritance). As the Child class has to
manage the dependency of more than one Parent class. But you can achieve multiple
inheritance in Java using Interfaces.
8. METHOD OVERLOADING
When two or more methods within the same class that have the same name, but their parameter
declarations are different
Example:
class demo
{
void test()
{
System.out.println("No parameters");
}
void test(int a)
{
System.out.println("a: " + a);
}
void test(int a, int b)
{
System.out.println("a and b: " + a + " " + b);
}
}
class Overload
{
public static void main(String args[])
{
demo ob = new demo();
ob.test();
ob.test(10);
ob.test(10, 20);
13
}}
9. METHOD OVERRIDING
When a method in a subclass has the same name and type signature as a method in its
superclass, then the method in the subclass is said to override the method in the superclass.
Program:
public class ClassA
{
public void display()
{
System.out.println("class A method");
}}
public class ClassB extends ClassA
{
public void display()
{
System.out.println("class B method");
super();
}}
public static void main(String args[])
{
ClassB b = new ClassB();
b.dispB();
}}
10. Super( ) keyword
1. super() invokes the constructor of the parent class.
2. super.variable_name refers to the variable in the parent class.
3. super.method_name refers to the method of the parent class.
Program:
public class ClassA
{
public void display()
{
System.out.println("class A method");
}}
14
public class ClassB extends ClassA
{
public void display()
{
System.out.println("class B method");
super();
}}
public static void main(String args[])
{
ClassB b = new ClassB();
b.dispB();
}}
11. INTERFACE IN JAVA
An interface in java is a blueprint of a class. It has static constants and abstract methods.
The interface in java is a mechanism to achieve abstraction and multiple inheritance.
Interface is declared by using interface keyword. It provides total abstraction; means
all the methods in interface are declared with empty body and are public and all fields
are public, static and final by default. A class that implement interface must implement
all the methods declared in the interface.
Syntax:
interface
{
// declare constant fields
// declare methods that abstract
// by default.
}
Program:
interface Printable
{
void print();
void show();
}
class A implements Printable
{
15
public void print()
{
System.out.println("Hello");
}
public void show()
{
System.out.println("Welcome");
}
public static void main(String args[])
{
A obj = new A();
obj.print();
obj.show();
}}
12. MULTIPLE INHERITANCE
Program:
interface Printable
{
void print();
void show();
}
class A implements Printable
{
public void print()
{
System.out.println("Hello");
}
public void show()
{
System.out.println("Welcome");
}
public static void main(String args[])
{
A obj = new A();
16
obj.print();
obj.show();
}}
13. ABSTRACT CLASS
A class that is declared with abstract keyword, is known as abstract class in java. It can
have abstract and non-abstract methods (method with body). Abstraction is a process
of hiding the implementation details and showing only functionality to the user.
Program:
abstract class Printable
{
abstract void print();
}
class A extends Printable
{
public void print()
{
System.out.println("Hello");
}
public static void main(String args[])
{
A obj = new A();
obj.print();
}
}
14. PACKAGES:
PACKAGES A java package is a group of similar types of classes, interfaces and sub-
packages. Package in java can be categorized in two form, built-in package and user-
defined package. There are many built-in packages such as java, lang, awt, javax,
swing, net, io, util, sql etc.
Advantage of Java Package
1) Java package is used to categorize the classes and interfaces so that they can be easily
maintained.
2) Java package provides access protection.
3) Java package removes naming collision.
17
Defining a Package
To create a package include a package command as the first statement in a Java source
file. Any classes declared within that file will belong to the specified package. The
package statement defines a name space in which classes are stored. If package
statement is omitted, the class names are put into the default package, which has no
name.
Syntax:
package <fully qualified package name>;
package pkg; Here, pkg is the name of the package.
For example, the following statement creates a package called MyPackage.
package MyPackage;
Program:
package mypack;
public class add
{
public void addition( )
{
int a=100, b=200;
int c=a+b;
System.out.println( c);
}
}
Main class Program:
import mypack.add;
public class myclass
{
public static void main(String args[])
{
add a =new add( );
a.addition( );
}
}
18
15. EXCEPTION HANDLING
An exception is an abnormal condition that arises in a code sequence at run time. The
process of catching and handling the exceptions that are occurred at the run time of a
program is known as Exception handling.
Five Keywords:
try, catch, finally, throw, throws
try:
A try block is placed around the code that might generate an exception.
Catch:
A catch statement involves declaring the type of exception we are trying to catch.
Finally:
A finally block of code always executes, irrespective of occurrence of an exception
Throw:
Throw is used to invoke an exception explicitly
Throws:
Any exception that is thrown out of a method must be specified as such by a throws
clause.
Checked exceptions −A checked exception is an exception that occurs at the compile
time.
Unchecked exceptions − An unchecked exception is an exception that occurs at the
time of execution
Syntax:
try
{
//block of code to monitor for error
}
catch (ExceptionType1 object)
{
// exception handler
}
//…
finally
{
//block of code
19
}
Program:
import java.io.*;
class demo
{
public static void main(String args[])
{
try
{
int arr[ ]={1,2,3,4,5};
System.out.println(arr[5]);
try
{
int a=10/0;
}
}
catch(ArithmeticException e)
{
System.out.println(“divide by zero error”);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(“does not exist”);
}
Finally
{
System.out.println(“end of the program”);
}
}
}
Throw keyword:
Program:
import java.io.*;
class demo
20
{
public static void main(String args[])
{
try
{
int a=10/2;
throw new ArithmeticException( );
}
}
catch(ArithmeticException e)
{
System.out.println(“divide by zero error”);
}
}
}
Throws keyword:
Syntax:
returntype method_name( ) throws exception class name
{
//block of code
}
Program:
import java.io.*;
class demo
{
void divide( ) throws Exception
{
Int a=10/0;
}
}
class main
{
public static void main(String args[ ])
{
21
demo d=new demo( );
try
{
d.divide( );
}
catch(Exception e)
{
System.out.println(e);
}
}
}
16. USER DEFINED EXCEPTION
We create our own exception that are derived classes of Exception class
Program:
import java.io.*;
import java.util.Scanner;
class NotValidException extends Exception
{
public NotValidException (String s)
{
super(s);
}
}
class demo
{
public static void main(String args[ ])
{
Scanner sc=new Scanner(System.in)
try
{
int age=sc.nextInt()
{
if(age<18)
{
22
throw new NotValidException(“age should greater than 18”);
}
}
catch(NotValidException e)
{
System.out.println(e);
}
}
}
17. MULTITHREADING
A multithreaded program contains two or more parts that can run concurrently. Each
part of such a program is called a thread, and each thread defines a separate path of
execution
Creation Of Thread Thread Can Be Implemented In Two Ways
1) Implementing Runnable Interface
2) Extending Thread Class
1. Extending Thread Class
Program:
public class A extends Thread
{
public void run()
{
try
{
for (int i = 1; i <5; i++)
{
System.out.println("thread 1”);
Thread.sleep(1000);
}
}
catch (InterruptedException e)
{
System.out.println("Child interrupted");
}
23
}
}
public class B extends Thread
{
public void run()
{
try
{
for (int i = 1; i <5; i++)
{
System.out.println("thread 2”);
Thread.sleep(1000);
}
}
catch (InterruptedException e)
{
System.out.println("Child interrupted");
}
}
}
public class main
{
public static void main(String[] args)
{
A t1=new A();
B t2=new B();
t1.start();
t2.start();
}
}
2. Create Thread by Implementing Runnable
Program:
public class A implements Runnable
{
24
public void run()
{
try
{
for (int i = 1; i <5; i++)
{
System.out.println("thread 1”);
Thread.sleep(1000);
}
}
catch (InterruptedException e)
{
System.out.println("Child interrupted");
}
}
}
public class B implements Runnable
{
public void run()
{
try
{
for (int i = 1; i <5; i++)
{
System.out.println("thread 2”);
Thread.sleep(1000);
}
}
catch (InterruptedException e)
{
System.out.println("Child interrupted");
}
}
}
25
public class main
{
public static void main(String[] args)
{
A t1=new A();
B t2=new B();
Thread s1=new Thread(t1);
s1.start();
Thread s2=new Thread(t2);
s2.start();
}
}
18. READING AND WRITING FILES
STREAM
A stream can be defined as a sequence of data. there are two kinds of Streams
InputStream: The InputStream is used to read data from a source.
OutputStream: the OutputStream is used for writing data to a destination.
Byte Streams
Java byte streams are used to perform input and output of 8-bit bytes
FileInputStream , FileOutputStream.
Character Streams
Java Character streams are used to perform input and output for 16-bit unicode.
FileReader , FileWriter
FileInputStream
This stream is used for reading data from the files. Objects can be created using the
keyword new.
Writing a file:
Program:
import java.io.*;
class RWfile
{
public static void main(String args[ ])
{
try
26
{
FileOutputStream fout=new FileOutputStream(“abc.txt”);
String s=”Reading and writing a file”;
byte b[]=s.getBytes( );
fout.write(b);
fout.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Reading a file:
Program
import java.io.*;
class WRfile
{
public static void main(String args[])throws Exception
{
FileInputStream fin=new FileInputStream(“abc.txt”);
int i=0;
while((i=fin.read( ))!=-1)
{
System.out.println((char)i);
}
fin.close( );
}
}
19. READING AND WRITING CONSOLE I/O
Program to read characters from the console
class readdemo
{
public static void main(String args[])throws Exception
27
{
char c;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println(“enter character ‘q’ to quit);
do
{
c=(char)br.read( );
System.out.println(c);
}
while(c!=’q’);
}
}
Writing console output:
Program:
import java.io.*;
public class writedemo
{
public static void main(String args[])
{
PrintWriter pw=new PrintWriter(System.out,true);
pw.println(“this is string”);
int i=-7;
pw.println(i);
}
}
20. GENERIC PROGRAMMING
Generic programming enables the programmer to create classes,interfaces and methods
that automatically works with all types of data(Integer, String, Float etc). It has
expanded the ability to reuse the code safely and easily.
Advantage of Java Generics There are mainly 3 advantages of generics. They are as
follows:
1)Type-safety : We can hold only a single type of objects in generics. It doesn’t allow
to store other objects.
2)Type casting is not required: There is no need to typecast the object.
28
3)Compile-Time Checking: It is checked at compile time so problem will not occur at
runtime. The good programming strategy says it is far better to handle the problem at
compile time than runtime.
GENERIC CLASS:
A class that can refer to any type is known as generic class. Generic class declaration defines
set of parameterized type one for each possible invocation of the type parameters
Program:
class demo <T>
{
T a;
demo(T a)
{
this.a=a;
}
void print();
{
System.out.println(a);
}
}
public class main
{
public static void main(String args[])
{
demo<Integer>d1=new demo<Integer>(10);
d1.print();
demo<String>d2=new demo<String>(“java”);
d2.print();
}
}
GENERIC METHOD:
Like generic class, we can create generic method that can accept any type of argument
Program
public class Test
{
29
public static < E > void print (E[] elements)
{
for ( E element : elements)
{
System.out.println(element );
}
}
public static void main( String args[] )
{
Integer[] intArray = { 10, 20, 30, 40, 50 };
Character[] charArray = { 'J', 'A', 'V', 'A'};
System.out.println( "Printing Integer Array" );
print ( intArray );
System.out.println( "Printing Character Array" );
print ( charArray );
}
}
Restrictions on Generics
• Cannot Instantiate Generic Types with Primitive Types
• Cannot Create Instances of Type Parameters
• Cannot Declare Static Fields Whose Types are Type Parameters
• Cannot Use Casts or instanceof With Parameterized Types
• Cannot Create Arrays of Parameterized Types
• Cannot Create, Catch, or Throw Objects of Parameterized Types
• Cannot Overload a Method Where the Formal Parameter Types of Each Overload Erase to
the Same Raw Type
21. STRINGS
In java, string is basically an object that represents sequence of char values. Java String
provides a lot of concepts that can be performed on a string such as compare, concat,
equals, split, length, replace, compareTo, substring etc.
In java, string objects are immutable. Immutable simply means unmodifiable or
unchangeable.
String s="java";
30
There are two ways to create String object:
1. By string literal
2. By new keyword
1) String Literal Java String literal is created by using double quotes. For Example:
String s="welcome";
2) By new keyword String s=new String("Welcome");
Program:
class stringmethod
{
public static void main(String args[ ])
{
String s1=new String(“java”);
String s2=”program”;
System.out.println(“length:”+s1.length());
System.out.println(“find”+s1.charAt(2));
System.out.println(“equals:”+s1.equals(s2));
System.out.println(“index:”+s1.indexOf(“gram”));
System.out.println(“concat:”+s1.concat(“programming”));
System.out.println(“replace:”+s1.replace(‘a’,’*’));
System.out.println(“uppercase:”+s1.toUpperCase ());
System.out.println(“substring:”+s2.substring(1,5));
System.out.println(“trim:”+s1.trim());
}
}
22. STRINGBUFFER
Java StringBuffer class is used to create mutable(modifiable) string objects.
StringBuffer s=new StringBuffer(“java”);
Program:
class stringbuffermethod
{
public static void main(String args[ ])
{
StringBuffer s1=new StringBuffer(“java”);
System.out.println(“append:”+s1.append(“program”));
31
System.out.println(“insert”+s1.insert(2,”program”));
System.out.println(“replace:”+s1.replace(1,3,”program”));
System.out.println(“delete:”+s1.delete(1,3));
System.out.println(“deletecharat:”+s1.deleteCharAt(2));
System.out.println(“reverse:”+s1.reverse());
}
}
23. JAVAFX
JavaFx is a set of graphics and media packages that enables developers to design, create,
test, debug and deploy rich client applications that operate consistently across diverse
platforms.
Components: stage, scene, node
Every Javafx application must be:
import javafx.application.Application;
public class demo extends Application
{
public void start(Stage primaryStage)throws Exception
{
//…
}
public static void main(String args[])
{
launch(args);
}
}
LAYOUT
Layout containers or panes can be used to allow for flexible and dynamic arrangements
of the UI controls within a scene graph of a javafx application. The javafx layout includes
• HBox
• VBox
• FlowPane
• GridPane
• BorderPane
• StackPane
32
MENU
A menu in javafx is a pop up window that contains a list of items. User can select an item from
the menu to trigger an action.
Constructor:
1. Menu()
2. Menu(String s)
3. Menu(String s, Node n)
4. Menu(String s, node n, MenuItem…i)
Program:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.*;
import javafx.scene.control.*;
import javafx.stage.Stage;
import java.io.*;
public class demo extends Application
{
public void start(Stage primaryStage)throws Exception
{
MenuBar mb=new MenuBar();
Menu f=new Menu("File");
Menu e=new Menu("Edit");
Menu v=new Menu("View");
mb.getMenus().add(f);
mb.getMenus().add(e);
mb.getMenus().add(v);
MenuItem m1=new MenuItem("New");
MenuItem m2=new MenuItem("New Window");
MenuItem m3=new MenuItem("Save");
MenuItem m4=new MenuItem("Open");
26
f.getItems().add(m1);
f.getItems().add(m2);
f.getItems().add(m3);
33
f.getItems().add(m4);
HBox root=new HBox();
root.getChildren().add(mb);
Scene sc=new Scene(root,600,600);
primaryStage.setScene(sc);
primaryStage.setTitle("notepad");
primaryStage.show();
}
public static void main(String args[])
{
launch();
}
}
EVENT HANDLING PROGRAM
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.*;
import javafx.scene.control.*;
import javafx.stage.Stage;
import java.io.*;
import javafx.event.*;
public class demo extends Application
{
public void start(Stage primaryStage)throws Exception
{
31
Button bt=new Button("Register");
Label l=new Label();
bt.setOnAction(new EventHandler<ActionEvent>()
{
public void handle(ActionEvent event)
{
l.setText("THANK YOU FOR REGISTRATION!!!!!");
}
34
});
VBox root=new VBox();
root.getChildren().addAll(bt,l);
Scene sc=new Scene(root,600,600);
primaryStage.setScene(sc);
primaryStage.setTitle("notepad");
primaryStage.show();
}
public static void main(String args[])
{
launch();
}
}
35