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

Please tell me what Object Oriented Programming and Object Based Programming with reallife example..what is the difference between them.?
Hi Ritesh, In order to be a true object oriented programming language, following 4 need to be present… 1) Abstraction - Hiding the implementation details from the user, only the functionality will...
Ritesh
What is the difference between Java and Advanced Java?
Java = Core + Advance(Servlets, JSPs & EJB)
Anu
What is the use of deployment descriptor?
A deployment descriptor describes how a component, module or application should be deployed. A web application’s deployment descriptor describes the classes, resources and configuration of the application...
Monisha
What is a constructor in Java?
Constructor is a special method to initialise Java objects. Usually initialisation logic is kept inside the constructor. Java compiler by default creates a default no arg constructor if no constructor is defined already.
Rishu
0 0
5
Which is the best programming language to learn in today's era? Java, C,C++, Python or any else?
Java is the best language because it is platform indepedent and opensource u can download java software at anywhere
Swati
0 0
5

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

Ask a Question

Related Lessons

Palindrome Number : Java Function
An easier way to find out whether a number is a Palindrome number or not. Eg. 121, 88, 12321 etc public boolean isPalindrome ( int n ) { int rev = 0, r; for( i = n; i > 0; i /= 10 ) { r...

Inheritance In Java
Inheritance: The process of getting properties and behaviors from one class to another class is called inheritance. Properties: Variables Behaviors: Methods The main purpose of the inheritance...
D

Deleted U.

1 0
0

Overloading in JAVA
When a class contains more than one method with the same method name but different argument types, then it is called Overloading. Methods are said to be Overloaded methods. Also, know as Compile time...

Java Hash Map internal implementation
1.Hash Map internal implementation: In hash map it will create an array of table (to store the {Key,Value} pair) which is of type java.util.HashMap.EntryThe Entry object contains {hash, key, next, value}...
R

Java 8 Predicates
In the previous lession, we have learnt how to use filters and collectors. In filter we have passed the condition to evaluate whether the object is eligible to be filtered or not. Code given below for...

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