• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Abstract method

 
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.examulator.com
link question

What will happen when you attempt to compile and run the following code?


1) Compile time error, synchronized can only be used in a class that extends Thread
2) Compile time error, malformed method getFireStation in class Hall.
3) Compilation and output of opposite at runtime
4) Compile time error, code within main method is incorrect.

Answer is 3.Abstract method is implemented in subclass with synchronized on it.what is the use of this manner?This is the first time i have got questions in absract method like this? In what other ways of abstract method implemented in subclass in different ways?Please guide me.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A non synchronized method can be override to synchronized and vice versa.
 
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Synochronized modifier is used to make a method accessible to only one thread at a time. This is done by obtaining a lock on a object from which that method was invoked. Any other thread is denied to access that method using SAME object.

You'll learn more about synchronization in THREADS.
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic