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

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

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

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

Assistant Professor With 2 Yrs Experience

To explain this in one sentence, "An abstract class has a protected constructor (by default) allowing only derived types to initialize it." What would happen when you call an abstract method? There would be no actual implementation of the method to invoke. So, the CLI would reject it.
Comments

Assistant Professor With 2 Yrs Experience

To putting your query in a single statement "An abstract class has a protected constructor (by default) allowing derived types to initialize it." Without a derived type where would the data go? What would happen when you call an abstract method? There would be no actual implementation of the method to...
Comments

JAVA J2EE trainer

We create an Abstract class in JAVA when we do not want to instantiate an Object. We do this when we are not sure of the implementation of all the methods in the class or we simply do not want to instantiate it. Most classic example is Shape and it's subclasses Rectangle, Triangle etc. Here for some...
read more
We create an Abstract class in JAVA when we do not want to instantiate an Object. We do this when we are not sure of the implementation of all the methods in the class or we simply do not want to instantiate it. Most classic example is Shape and it's subclasses Rectangle, Triangle etc. Here for some method area(), implementation will be different for all sub classes and for the superclass Shape we may not know it's implementaion. So we can simply mark that method abstarct and so the class is also Abstract. For exact implentation rules, you can check many tutorials available. And so it becomes comparable to an Interface. For your second question, please note the methods wait(), notify() and soforth are always applied on the state of the Object and not the Thread that is why they are present in Object class and not Thread class. read less
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

Abstract class is meant for acting the class as a parent. so inorder to restrict the class being used as it is. java has set this rule. but u can still access the instance methods and variable by subclassing the class.
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

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

View 13 more Answers

Related Questions

Need to do java core and advanced certificate. Which books or pdf is need to refer?
Hi Prashanth, At first to be clear there is nothing called Core and Advance certificate, Its OCJP/SCJP Certification. The cost and other details are already mentioned in their respective portals. The...
Prashanth
What's New in JDK 8 ?
1.Lamda Expressions I started with lambda expressions as this is probably the most sought after feature in the language after probably Generics/Annotations in Java 5. 2.Generic Type changes and improvements Taking...
Ashish
What is the best site to learn Java for development?
www.javatpoint.com Is best site to learn and earn knowledge
Chai
0 0
8

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

Ask a Question

Related Lessons

JAVA - Object Cloning
JAVA - Object Cloning Is the way of creating the same copy of object without calling the class constructor. It means we can make any class object multiple times without calling its default constructor....

Tips of learning Java Language/Other Programming Languages
1.You should know the basic concept: If we talk about programming languages so basic concept are same in all the high level languages. So you should know the basic concept firstly then you can easily understand...
I

ICreative Solution

0 0
0

Interview Tip : Q1) Why Strings are immutable in java ? What happen if it was mutable in java?
As we all know that Strings in java are immutabe in nature, now the question comes why the creator made it immutable in nature, although this field used maximum in any java program. The answer to this...

TestNG Annotations and its sequence
public class TestNGAnnotations { @BeforeMethod public void beforeM() { System.out.println("Before Method"); } @AfterMethod public void afterMethod() { System.out.println("After Method"); } @BeforeClass...
S

Sarthak C.

0 0
0

Introduction to Course Content
Video about what we are going to learn throughout the Java Training Session .

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