UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

why can't we create an object for abstract class? why wait,notify,notifyall methods were in object class but not in thread class?

Asked by Last Modified  

15 Answers

Learn Java

Follow 0
Answer

Please enter your answer

Abstract class is having an abstract method. It is empty method, created for future requirements, therefore usage is not certain by specifying objects to it.
Comments

Java/J2EE Trainer

The Generalized object can be a abstract class in the sense. Consider we have three object Employee, Manager, and Engineer we can establish the relationship like Manager extends Employee , Engineer extends Employete like that. When we create polymorphic object like Employee jo hn= null; john = new...
read more
The Generalized object can be a abstract class in the sense. Consider we have three object Employee, Manager, and Engineer we can establish the relationship like Manager extends Employee , Engineer extends Employete like that. When we create polymorphic object like Employee jo hn= null; john = new Manager(); //later john = new Engineer(); Now I can say "john" is polymorphic object just think now. this statement Employee john = new Employee(); it is not a meaningful what we going to do with top level Employee object but I can say Employee john = new Manager() or Employee john = new Engineer.. So the better OO Principle is the generalized class or object or entity can be a abstract class. in this case Employee can be abstract class. read less
Comments

Senior Software Professional (google:sknandi)

1. 'Why can't we create an object for abstract class?' Abstract class do not have any physical existence: Animal - Abstract super class Cat, Dog, Cow - Subclass of 'Animal' You can see Cat, Dog, Cow are roaming around physically but not Animal that way. 2. Why wait, notify, notifyall methods were...
read more
1. 'Why can't we create an object for abstract class?' Abstract class do not have any physical existence: Animal - Abstract super class Cat, Dog, Cow - Subclass of 'Animal' You can see Cat, Dog, Cow are roaming around physically but not Animal that way. 2. Why wait, notify, notifyall methods were in object class but not in thread class? If they would be there in the Thread class then in cases where you would create thread using Runnable instance (using object having 'Runnable' implementation) those wait, notify, notifyall methods would not be available - you had to write your own. Since they are defined in the Object class, we could use them in the above scenario today. read less
Comments

Java Bean

Everybody says, we can't able to create instance for abstract class because it has one or more abstract methods and incomplete detail of particular functionality. I agree that such functionality don't have complete details so we make those as abstract method and that contained class is abstract. Let's...
read more
Everybody says, we can't able to create instance for abstract class because it has one or more abstract methods and incomplete detail of particular functionality. I agree that such functionality don't have complete details so we make those as abstract method and that contained class is abstract. Let's now assume that you not in java world, now think that everything is possible, abstract class can also be instantiated now [ object can be created ]. Take example of Car, which has non-abstract method engine() and brake(), and accelrate() same for all cars and some of abstract methods getCarNo(), getColor() are unique for each car, so we declaring these two class es as abstract class. abstract class Car { private Engine engine; private Break _break; private Accelrater accel; public Engine getEngin() { return this.engine; } public void setEngine(Engine engine) { this.engine = engine; } public Break getBreak() { return this._break; } public void setBreak(Break _break) { this._break = _break; } public Accelrater getAccelrate() { return this.accel; } public void setAccelrate(Accelrater accel) { this.accel = accel; } abstract public void getColor(); abstract public void getCarNo(); } if you now try like these Car car = new Car(); // assume it happens car.setEngine(new Engine() ); // fine ok, car.getEngine(); // fine ok, both can executed because both have body same case with other non-abstract method if you this car.getColor(); car.getCarNo(); // its like you are asking something to car class which that doesn't have When you try to access abstract method using abstract class object, it have only declaration but not definition. For this reason they don't allowed creation of object for abstract class, because some persons like me may try to access such methods if they allowed such things.... Lets take, we can't create object for abstract class but we can hold reference of child class.... why this is allowed, let give some work to mind read less
Comments

Java, Spring and Restful Web Service Training

1. As abstract meaning indicates, Abstract class will have an design prototypes. Ideally declaring all methods prototypes and Class need to implement those methods which are extending the Abstract class. suppose 2 classes extending the abstract class and both classes implementing all abstract methods....
read more
1. As abstract meaning indicates, Abstract class will have an design prototypes. Ideally declaring all methods prototypes and Class need to implement those methods which are extending the Abstract class. suppose 2 classes extending the abstract class and both classes implementing all abstract methods. if java allows to create the object of abstract class then compiler will gets ambiguity which method need to class since 2 classes extending abstract class due to this reason Java does not allow to create the object for abstract class to make the design is simple. 2. Initial basic understanding is wait, notify and notifyAll methods are used for inter-thread communication. Synchronize key is used for mutual exclusion. In multithreading environment threads will communicate each other. In order to avoid race condition we will use Synchronize keyword. Reasons for wait and notify methods are part of object class as listed below. 1. locks are made available on object instead of threads . 2. Threads will wait for lock or hold lock but we dont know which thread is waiting for lock instead it know waiting on which object. 3. Object class is the right place to keep all these methods wait, notify, any thread can communicate with another thread by using locks (waiting on object) by using wait and notify methods. read less
Comments

Abstract by its meaning points to something not concrete or not not.defined, same with java. In java abstract means a class or a method that can be either defined or leave it abstract to be overridden by the child class..for example if we have a Car as a class with methods like brake(),accelrate() defined...
read more
Abstract by its meaning points to something not concrete or not not.defined, same with java. In java abstract means a class or a method that can be either defined or leave it abstract to be overridden by the child class..for example if we have a Car as a class with methods like brake(),accelrate() defined but we will have to leave getColor() as abstract because we dont know or cant define one color for all cars so that makes class Car as abstract since.some of its.details will be defined or rather better implemented by its child classe and hence instantiating a class with incomplete behavior doesnt make sense therefore abstract classes cannot be instantiated. The methods wait,notify and notifyAll work on the object on which the thread has obtained a lock on hence when the task is complete on that object it is the objects duty to notify the thread to release the lock or notify other threads about its completion.or status...hence these methods are in object and since.Object is global parent class in Java i.e. parent class.of every class by default, and therefore these methods are available in Thread class as well read less
Comments

Abstract class is having an abstract method. It is empty method, created for future requirements, therefore usage is not certain by specifying objects to it.
Comments

Java Tutor 6 years of IT Industry Experience

Abstract classes are not complete classes, hence we cant not create an object of Abstract classes. Wait, Notify and NotifyAll methods are in Object class to serve the purpose of MultiThreading.
Comments

Computer Software, Training, Corporate Training

Hi Jilani, Tom be very simple and short.... Any Object (not just a thread) can be the monitor for a thread. The wait and notify are called on the monitor. The running thread checks with the monitor. So the wait and notify methods are in Object and not Thread
Comments

Guide in your studies

Abstract classes are not complete. It does not have complete body i.e. class status is not clear so we cant create object. Compiler prevents the instantiation of such incomplete objects. This class doesn't have an implementation for one or more methods. It means that the jvm doesn't have any direction...
read more
Abstract classes are not complete. It does not have complete body i.e. class status is not clear so we cant create object. Compiler prevents the instantiation of such incomplete objects. This class doesn't have an implementation for one or more methods. It means that the jvm doesn't have any direction of what to do in case if someone calls the method which is abstract. Hence, it may be crashed. read less
Comments

View 13 more Answers

Related Questions

As a fresher I have done Python training, but hardly getting response from any company. What should I do?
only having training in Python is not enough to be called for intervew. Better you should get real time certification course form reputed organisation with smart hand-on real project exposure. Try to have...
Yamini
0 0
6
How do I show a popup message over a system tray icon/application in Java?
The java.awt.SystemTray class introduced in Java™ SE version 6 represents the system tray for a desktop. The system tray can be accessed by calling the static SystemTray.getSystemTray() method. Before...
Ajith
0 0
5
Should we learn DBMS and RDBMS without any Java training?
java or i can say any programming language is not required to learn DBMS or RDBMS
Karthik
0 0
6
What are the booming technologies in US from Job point of view
All the terminologies are good. First of all decide your self you want go as functional consultant or technical. If you have java background Learn Hadoop. Billing rate is very high.
Chandra

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Create Immutable Class
Snippet of an Immutable Class: package com.stringhr; /*Declare the class as 'final'. This would prevent any other class from extending it and hence from overriding any method from it which could modify...

Java Advantages
In this video, learn about Java and its advantages. Also, check out the difference between Java and C++, Java development kit, Java Run Time Environment (JRE) with a proper demonstration program for better clarity.

Advance Java
1) Servlet • Basics of Servlet • Servlet Request • Servlet Collaboration • Servlet Config • Servlet Context • Attribute • Session Tracking • Event and Listener •...
A

Design Pattern
Prototype Design Pattern: Ø Prototype pattern refers to creating duplicate object while keeping performance in mind. Ø This pattern involves implementing a prototype interface which tells...

ListIterator Example
public class ListIteratorEx { public static void main(String args) { List<String> li = new ArrayList<String>(); li.add("java1"); li.add("java2"); li.add("java3"); li.add("java4"); ListIterator...
S

Sarthak C.

0 0
0

Recommended Articles

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more