Free Online Whiteboard Base64 Converter JSON Utility SmartTool PDF

Category: Blog

Schedule a task and generate beep 0

Schedule a task and generate beep

Example that uses java.util.Timer to schedule a task to execute once 3 seconds have passed. ScheduleAndBeep.java import java.util.Timer; import java.util.TimerTask; import java.awt.Toolkit; public class ScheduleAndBeep { Toolkit toolkit; Timer timer; public ReminderBeep(int seconds) {...

DeadLock Example in Java 0

DeadLock Example in Java

FirstThread.java public class FirstThread { public synchronized void startProcess(SecondThread sec) throws Exception { String name = Thread.currentThread().getName(); System.out.println(name + ” Entered FirstThread.startProcess”); Thread.sleep(1000); System.out.println(“Trying to call SecondThread.last”); sec.last(); } public synchronized void last() throws...

When is abstract class used? 0

When is abstract class used?

abstract keyword is used to create a abstract class and method. Abstract class in java can’t be instantiated. An abstract class is mostly used to provide a base for subclasses to extend and implement...

When is an interface used? 0

When is an interface used?

A class that implement interface must implement all the methods declared in the interface. To implement interface use implements keyword. Since java does not support multiple inheritance in case of class, but by using...

Does Java have multiple inheritance? 0

Does Java have multiple inheritance?

Java does not support multiple inheritence directly but it does thru the concept of interfaces. We can make a class implement a number of interfaces if we want to achieve multiple inheritence type of...

How does exception handling work in Java? 0

How does exception handling work in Java?

1.It separates the working/functional code from the error-handling code by way of try-catch clauses. 2.It allows a clean path for error propagation. If the called method encounters a situation it can’t manage, it can...