Is statement a above legal or is casting required explain

Assignment Help Computer Engineering
Reference no: EM13812577

Create a Word document containing the answers to all the problems given below.

1. What is an abstract class and how does it differ from a regular class?

2. Why are abstract class constructors defined as protected?

3. Class X defines method M1( ) as abstract. Class Y inherits from Class X and implements the method M1( ). Given the following code, explain why a reference to the abstract class X is allowed to refer to an object of the concrete class Y. Explain what happens when the reference to the abstract class X is used to execute method M1( ). X obj = new Y( ); obj.M1( );

4. What are interfaces allowed to contain?

5. Define a simple interface named Motorized with one method (maxSpeed) which returns the maximum attainable speed and another method (fuelType) which returns the type of fuel required.

6. Given the interface defined in question 5, if a class named Motorcycle implements this interface, explain why the following code is legal. What happens when the interface reference vehicle invokes the maxSpeed method?

Motorized vehicle = new Motorcycle( );

System.out.print("The max speed is %d\n", vehicle.maxSpeed( ) );

7. What is an event object? Give an example.

8. What is an event source? Give an example.

9. What is an event listener? Give an example.

10. What is a nested inner class? What special privileges does a nested inner class have? Give an example of how you declare a nested inner class.

11. You are writing a simple GUI application using a class called MyGuiClass. Your GUI will have a JButton which your program will need to respond to when it is clicked. Describe what you would need to do to setup event handling using a nested inner class. Use Java code fragments in your answer.

12. If the GUI in the above example had three JButtons, how would you change your actionPerformed method to handle events from the three different buttons?

13. Here are some class definitions with questions that follow. interface MyInterface

{

// Methods of MyInterface

}

public SomeClass implements MyInterface

{

// All methods of SomeClass and MyInterface

}
SomeClass obj = new SomeClass( );
a. MyInterface miobj = obj;

b. SomeClass obj2 = miobj;

c. miobj.aMethodOfSomeClass( );

A. Is statement a above legal, or is casting required? Explain.

B. Statement b is trying to assign the SomeClass object refered to by miobj to a SomeClass reference variable obj2. What is wrong with this statement and how would you fix it.

C. In statement c, an interface reference is trying to access a SomeClass class method that is not part of MyInterface. Is this legal? Explain.

Reference no: EM13812577

Questions Cloud

Cage framework to evaluate international trade opportunities : List the key ideas you have extracted from the prescribed e-learning activity -  ideas and explain how the ideas should be applied.
Differences between data, voice, and video signals : Differences between data, voice, and video signals.  Include a description comparing the differences between a PBX and VoIP.  (200-350 words)
What evidence is cited to support the arguments : What are the arguments in favor of non-organic? What are the arguments in favor of organic? What evidence is cited to support these arguments? What relationship does his paper have with our studies?
What are the components needed for voice over ip systems : Are private branch exchange phone systems less expensive than voice over IP?  What are the components needed for voice over IP systems?
Is statement a above legal or is casting required explain : What is an abstract class and how does it differ from a regular class? Is statement a above legal, or is casting required? Explain
Voluntary disclosure reporting program within a safety : Voluntary Disclosure Reporting Program within a Safety Assurance
Write an essay on differences between puritans and calvinism : Write an essay paper on the association and differences between Puritans and Calvinism and how it relates to the short story "Young Goodman Brown."
Created a database and a db schema : Created a database and a DB Schema It provides details of table, relationships and keys incorporating the profile detail.
Detailed security requirements for inclusion in an rfp : Document 20 detailed security requirements for inclusion in an RFP. These requirements should focus specifically on security of the logon process (authentication) of users into a networked application.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd