computer programming

  1. Can you access an instance variable from a static method? Explain why or why not.


  1. Can you access a static variable from an instance method? Explain why or why not.

  2. Consider the case where you have two classes, ClassA and ClassB, such that ClassA contains a member variable defined as ClassB myBobj. ClassB contains a constructor which takes a String parameter. ClassA provides a constructor which accepts a String parameter which is to be provided to myBobj. What needs to be done to initialize the ClassB member variable with the value from the ClassA constructor?

  3. Here are some class definitions with questions that follow.


public class BaseClass { // methods of BaseClass }

public SomeClass  extends BaseClass

            { // methods of SomeClass }


a.       SomeClass scobj = new SomeClass( );

b.      BaseClass bcobj = scobj;

c.       SomeClass scobj2 = bcobj;

d.     bcobj.aMethodOfSomeClass( ); // does not exist in BaseClass


A.     Is statement babove legal, or is casting required?


B.     Statement c is trying to assign the SomeClass object referred to by bcobj to a SomeClass reference variable scobj2. What is wrong with this statement and how would you fix it.


C.     In statement d, a BaseClass reference is trying to access a SomeClass class method that is not part of BaseClass. Is this legal? Explain.


  1. Give an example using Java syntax of how some class Y can be setup to inherit from some other class X.


  1. What is a significant difference between C++ and Java inheritance?


  1. How is the keyword super used? Give two different uses for it and include Java examples.


  1. Explain the difference betweenpublicprivate, and protectedaccess specifiers. Give some guidelines of when each should be used.


  1. Explain what package access means and how it is specified.


  1. What can you do in Java to prevent a method from being overridden in a derived class? Give example code in your answer.


  1. How do you prevent a class from being extended? Give example code in your answer.


  1. Explain how dynamic binding works in Java.






Needs help with similar assignment?

We are available 24x7 to deliver the best services and assignment ready within 3-4 hours? Order a custom-written, plagiarism-free paper

Get Answer Over WhatsApp Order Paper Now

Do you have an upcoming essay or assignment due?

All of our assignments are originally produced, unique, and free of plagiarism.

If yes Order Paper Now