PLAGIARISM FREE WRITING SERVICE
We accept
MONEY BACK GUARANTEE
100%
QUALITY

Modern Programming Tools And Techniques Computer Technology Essay

Content
  1. Q:1 Define abstraction, encapsulation, modularity and hierarchy in your own terms.
  2. Encapsulation
  3. Modularity
  4. Hierarchy (Inheritance)
  1. Single Inheritance
  2. Multiple Inheritance
  3. Q:2 Sketch the object-oriented design or the Cards game Black-Jack. What are the key things? What are the properties and behaviours of these objects? How does the thing interact
  4.  
  5.  
  6.  
  7. Q:3 Sketch the object-oriented design of something to control a Soda dispensing machine. What are the key things? What are the properties and behaviours of the objects? How can the thing interact?
  8. ANS:-
  9. The express machine's software is encapsulated in the "wrapper" class. The wrappee hierarchy's program mirrors the wrapper's software apart from one additional parameter. The extra parameter allows wrappee produced classes to call back to the wrapper class as necessary. Intricacy that would usually drag down the wrapper course is neatly compartmented and encapsulated in a polymorphic hierarchy to that your wrapper thing delegates.
  10. Example
  11. .
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. Part B
  28. Q:4 In an object oriented inheritance hierarchy, the objects at each level tend to be specialized than the things at the higher levels. Give three real life examples of a hierarchy with this property.
  29. Class hierarchies
  30. Real exemplory case of hyrarchy
  31.  
  32.  
  33.  
  34.  
  35. Define a java frequent equal to 2. 9979 X 108 that approximates the acceleration of light in
  36. meters per second.
  37. 2. 9979E+8
  38. Q:6 Write a code segment that defines a Scanner variable stdin that is associated with System. in. The code segment should than define to int variables a and b, in a way that these are initialized with the next two input values from the standard type stream.
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. Q:7 Separately identify the keywords, parameters, classes, methods and guidelines in the following definition:
  47. import java. util. *;
  48. public class test
  49.  
  50. public static void main(String[] args)
  51.  
  52. Scanner stdin = new Scanning device(System. in);
  53. System. out. print out("Quantity:");
  54. double n = stdin. nextDouble();
  55. System. out. println(n + " * " + n + " = " + n * n);
  56.  
  57.  
  58. -
More...

Q:1 Define abstraction, encapsulation, modularity and hierarchy in your own terms.

Ans:-Abstraction"Abstraction denotes the essential characteristics associated with an Object that vary it from other things, and in so doing providing a boundary that is relative to the perspective of the viewer. " Abstraction focuses on the outside-view of the Object, and helps isolate its habit from its execution, Think of it this way, to you, your car is an utility that can help you commute, it has a tyre, brakes etc but from an technicians viewpoint the same car signifies an entirely different view point, to the engineer the car is an entity that is composed of sub elements such and engine with a certain horse power, a certain cubic capacity, its power conversion ratio etc. It's the same car that people are talking about, but its action and properties have been encapsulated to the perspective of the audience. This is exactly what abstraction is.

Encapsulation

"Encapsulation is wearing down the elements of an abstraction that constitute to its framework and action. Encapsulation provides as the program between abstraction and its implementation".

To understand encapsulation better, consider an animal such as a dog. We know a dog barks, it is its patterns, a property that defines a puppy, but what's hidden is, how it barks, its implementation, this is encapsulation. The concealing of the execution details of a habit that defines a house of an entity is Encapsulation.

Modularity

"The skill of partitioning an application into individual components so as to reduce its complexity

to some extent can be termed as Modularity" Furthermore, the department of the code into modules helps provide clear boundaries between various areas of the program, thus and can be better noted and defined. In other words Modularity is building abstraction into discrete items. The direct bearing of modularity in Java is the use of packages. Elements of Evaluation and Design

Hierarchy (Inheritance)

Abstraction is good, but in most real world cases we find more abstractions than we can comprehend at onetime, though Encapsulation can help us to hide the execution, and modularity to crisply cluster logically related abstractions, at times, it just isn't enough. This is when Hierarchy comes into the picture, a set of Abstractions mutually form a Hierarchy, by figuring out these hierarchies in our design; we greatly simplify our knowledge of the trouble.

Single Inheritance

Single Inheritance is the main part of "is - a" hierarchy. When a class stocks the"structure" of another course it is said to solo inherit a base class. To comprehend the concept better, let's try this. Consider the base category "Animal". To establish a bear terms of and animal, we say a Carry "is - a" kind of Canine. In simpler conditions, the bear sole inherits the structure of an canine.

Multiple Inheritance

Multiple Inheritance can be defined as a "part of" inheritance where in fact the subclasses inherit the "Patterns" of more than one bottom part type.

Q:2 Sketch the object-oriented design or the Cards game Black-Jack. What are the key things? What are the properties and behaviours of these objects? How does the thing interact

Ans:-Blackjack Implementation

It must write three new classes and link them challenging earlier classes in the job. The high grade, DealerHand, implements the algorithm of participating in Blackjack from the dealer's perspective.

The classcontains a field which keeps track of the existing number of details in a side, and a methodthat telephone calls in a counter-controlled loop the technique of the prior class GameDeck to deal

cards individually from the very best of the deck. As credit cards are being dealt, the current number of factors in the palm is updated consequently. Another approach to GameDeck returns the worthiness of the aforementioned field. The next category, PlayerHand, is a subclass of DealerHand. It overrides the method

for dealing cards: the cards are still dealt in a loop, however the loop is sentinel- handled this

time, and the technique incorporates interaction with an individual.

The third school, GameApp, provides the method main where objects of

DealerHand and PlayerHand are manufactured. Methods for working cards are invoked on these

objects. When these procedures return, the victor of the overall game is determined corresponding to

the standard Blackjack algorithm.

The specific details of the algorithms for determining things in each palm and for

determining the success of the game are determined by students with nearly no

assistance from the teacher. By this point in the course, the students have the ability to write

this code independently, taking a techniques, concepts, syntax and basic

structures of the Java words they have learned through the semester.

While the application could be made out of any development environment, Ibelieve that its success in my class is dependent upon the utilization of BlueJ. BlueJ permits this

project in two ways: (1) as an extremely simple-to-use tool for writing and editing and enhancing code, and (2)

through the provided test code that allows users to generate images onscreen without any

prior understanding of Java design (e. g. , the Swing API). Because BlueJ minimizes the

hurdles associated with images programming, amateur students are able to create an

interesting and fun request, which helps them grasp the fundamentals of the object-oriented

approach in the earliest stages of their CS coursework. As an example, suppose you want to create an application that plays the cards game, Blackjack. Youcan use the Card, Hand, and Deck classes developed. However, a submit the overall game of Blackjack is a little different from a palm of cards in general, since it must be possible to compute the "value" of the Blackjack hand based on the rules of the game. The guidelines are as follows: The worthiness of a palm is obtained with the addition of up the worth of the cards in the side. The value of an numeric card such as a three or a ten is its numerical value. The worthiness of any Jack, Queen, or King is 10. The worthiness of any Ace can be either 1 or 11. An Ace should be counted as 11 unless doing this would put the full total value of the hand over 21.

One way to handle this is to increase the existing Palm class by adding a way that computes the Blackjack value of the palm. Here's this is of such a category:

public category BlackjackHand extends Hands

public int getBlackjackValue()

// Returns the value of this hands for the

// game of Blackjack.

int val; // The value computed for the side.

boolean ace; // This can be place to true if the

// hand includes an ace.

int credit cards; // Quantity of credit cards in the hand.

val = 0;

ace = phony;

cards = getCardCount();

for ( int i = 0; i < cards; i++ )

// Add the value of the i-th cards in the side.

Card card; // The i-th credit card;

int cardVal; // The blackjack value of the i-th cards.

card = getCard(i);

cardVal = card. getValue(); // The standard value, 1 to 13.

if (cardVal > 10)

cardVal = 10; // To get a Jack, Queen, or King.

 

if (cardVal == 1)

ace = true; // There reaches least one ace.

 

val = val + cardVal;

 

// Now, val is the value of the hand, keeping track of any ace as 1.

// If there is an ace, in case changing its value from 1 to

// 11 would leave the credit score significantly less than or equal to 21,

// then do so by adding the extra 10 tips to val.

if ( ace == true && val + 10 <= 21 )

val = val + 10;

return val;

// end getBlackjackValue()

// end class BlackjackHand

Q:3 Sketch the object-oriented design of something to control a Soda dispensing machine. What are the key things? What are the properties and behaviours of the objects? How can the thing interact?

ANS:-

The express machine's software is encapsulated in the "wrapper" class. The wrappee hierarchy's program mirrors the wrapper's software apart from one additional parameter. The extra parameter allows wrappee produced classes to call back to the wrapper class as necessary. Intricacy that would usually drag down the wrapper course is neatly compartmented and encapsulated in a polymorphic hierarchy to that your wrapper thing delegates.

Example

The State style allows an subject to improve its habit when its internal condition changes. This routine can be observed in a vending machine. Vending machines have states based on the inventory, amount of money deposited, the ability to make change, that selected, etc. When money is deposited and a selection is made, a vending machine will either deliver a product and no change, deliver something and change, deliver no product due to insufficient currency on first deposit, or deliver no product as a consequence to inventory depletion.

Identify a preexisting category, or create a fresh class, that will serve as the "point out machine" from the client's point of view. That class is the "wrapper" class.

Create circumstances base class that replicates the techniques of the state machine software. Each method can take one additional parameter: an example of the wrapper course. The State bottom part course specifies any useful "default" action.

Create a State derived class for every domain status. These derived classes only override the methods they have to override.

The wrapper school maintains a "current" Point out object.

All client demands to the wrapper school are simply delegated to the present State subject, and the wrapper object's this pointer is handed down.

The Express methods change the "current" express in the wrapper thing as appropriate.

.

public category VendingMachine

private two times sales;

private int cans;

private int bottles;

 

open public VendingMachine()

fillMachine();

 

 

public void fillMachine()

sales = 0;

cans = 10;

bottles = 5;

 

 

general public int getCanCount() return this. cans;

general public int getBottleCount() return this. bottles;

public dual getSales() return this. sales;

 

general public void vendCan()

if (this. cans==0)

System. away. println("Sorry, out of cans. ");

else

this. cans -= 1;

this. sales += 0. 6;

 

 

 

 

 

 

public static void main(String[] argv)

VendingMachine machine = new VendingMachine();

 

 

 

Part B

Q:4 In an object oriented inheritance hierarchy, the objects at each level tend to be specialized than the things at the higher levels. Give three real life examples of a hierarchy with this property.

ANS:- Solitary Inheritance

Java implements what is known as a single-inheritance model. A fresh class can subclass (lengthen, in Java terminology) only 1 other class. In the end, all classes eventually inherit from the thing class, developing a tree framework with Object as its main. This picture illustrates the school hierarchy of the classes in the Java electricity package deal, java. util

The HashTable category is a subclass of Dictionary, which in turn is a subclass of Subject. Dictionary inherits all of Object's factors and methods (habit), then provides new factors and behavior of its own. Similarly, HashTable inherits all of Object's variables and patterns, plus all of Dictionary's factors and action, and continues on to add its own variables and patterns.

Then the Properties course subclasses HashTable subsequently, inheriting all the variables and patterns of its school hierarchy. In the same way, Stack and ObserverList are subclasses of Vector, which is a subclass of Object. The power of the object-oriented methodology is apparent--none of the subclasses had a need to re-implement the basic functionality of their superclasses, but needed only add their own particular behavior.

However, the above diagram highlights the slight weakness with the single-inheritance model. Notice that there are two different varieties of enumerator classes in the picture, both of which inherit from Subject. An enumerator class

implements patterns that iterates by using a collection, obtaining the components of that collection one at a time. The enumerator classes define action that both HashTable and Vector find useful. Other, up to now undefined collection classes, such as list or queue, could also need the habit of the enumeration classes. Regrettably, they can inherit from only one superclass.

A possible method to solve this problem would be to enhance some superclass in the hierarchy to add such useful behavior when it becomes noticeable that many subclasses could use the behavior. Such an procedure would lead to chaos and bloat. If each time some typically common useful patterns were necessary for all following subclasses, a course such as Subject would be undergoing constant changes, would develop to gigantic size and complexity, and the specification of its tendencies would be constantly changing. Such a "solution" is untenable. The beautiful and workable means to fix the condition is provided via Java interfaces, the subject of the next theme.

Multiple inheritance

Some object-oriented development dialects, such as C++, allow a class to extend two or more superclasses. This is called multiple inheritance. Within the illustration below, for example, course E is shown as having both school A and course B as direct superclasses, while class F has three immediate superclasses.

Such multiple inheritance is prohibited in Java. The designers of Java wished to keep the terms fairly simple, and thought that the benefits associated with multiple inheritance weren't worth the cost in increased difficulty. However, Java has a feature that can be used to accomplish lots of the same goals as multiple inheritance: interfaces.

Class hierarchies

Classes in Java form hierarchies. These hierarchies are similar in framework to numerous more

familiar classification constructions including the group of the natural world

originally developed by the Swedish botanist Carl Linnaeus in the 18th century. Portions

of this hierarchy are shown in the diagram. At the top of the graph is the

universal category of all living things. That category is subdivided into several

kingdoms, that happen to be in turn broken down by phylum, class, order, family, genus, and

species. In the bottom of the hierarchy is the type of creature that

biologists name using the genus and varieties together. In cases like this, the bottom of the

hierarchy is occupied by Iridomyrmex purpureus, which really is a kind of red ant. The

individual red ants on the planet match the items in a programming language.

Thus, each of the individuals

is an instance of the types purpureus. By virtue of the hierarchy, however, that

individual is also an instance of the genus Iridomyrmex, the course Insecta, and the phylum

Arthropoda. It is likewise, of course, both an animal and a living thing. Moreover, each

red ant gets the characteristics that pertain to each of its ancestor categories. For example,

red ants have six thighs, which is one of the defining characteristics of the course Insecta.

Real exemplory case of hyrarchy

Ques5 How do methods System. away. print() and System. away. println() differ? Explain a java frequent add up to 2. 9979 X 108 that approximates the quickness of light in meters per second.

ANS:-1) public school Area

public static void main(String[] args)

int size = 10;

int width = 5;

// calling the technique or employing it

int theArea = calculateArea();

System. away. println(theArea);

 

// our declaration of the method

public static int calculateArea()

int methodArea = size * width;

return methodArea;

 

 

2) general public static void printHeader()

System. out. println("Feral Creation");

System. out. println("For all your Forest Videos");

System. away. println("427 Blackbutt Way");

System. away. println("Chaelundi Forest");

System. away. println("NSW 2473");

System. away. println("Australia");

 

System. out. println("String discussion")

System. out. print("String discussion")

In the first case, the code fragment accesses the println() approach to the object described by the category variable named out of the class named System. In the next case, the print() method is seen instead of the println() method

The difference between the two is that the println() method automatically inserts a newlineat the end of the string debate whereas the print() method leaves the screen cursor by the end of the string argument

Define a java frequent equal to 2. 9979 X 108 that approximates the acceleration of light in

meters per second.

Floating-point values can be written in a special programmer's design of scientific notation, in which the value is displayed as a floating-point amount multiplied by aintegral ability of 10. To write a number by using this style, you write a floating-point number in standard notation, implemented immediately by the letter E and an integerexponent, optionally preceded by the + or - indication. For instance, the acceleration of light inmeters per second is approximately

2. 9979 x 108

which can be written in Java as

2. 9979E+8

where the E stands for what times 10 to the power. Boolean constants and identity constants also exist and are referred to in subsequent chapters along with their equivalent types.

Q:6 Write a code segment that defines a Scanner variable stdin that is associated with System. in. The code segment should than define to int variables a and b, in a way that these are initialized with the next two input values from the standard type stream.

Ans:-

Import java. util. *;

Public school mathfun

 

Public static void main(string[] args)

 

Scanner stdin=new scanning device (system. in);

System. out. print out("enter a decimal amount");

Double x=stdin. nextdouble();

System. out. print out(enter another decimalnumber");

Double y=stdin. nextdouble();

Double squarerootx=math. sqrt(x);

System. away. println("square reason behind "+x+"is+square rootx);

 

 

 

System. out. println("Person\tHeight\tShoe size");

System. away. println("=========================");

System. away. println("Hannah\t5'1\"\t7");

System. away. println("Jenna\t5'10\"\t9");

System. out. println("JJ\t6'1\"\t14");

 

 

Q:7 Separately identify the keywords, parameters, classes, methods and guidelines in the following definition:

import java. util. *;

public class test

 

public static void main(String[] args)

 

Scanner stdin = new Scanning device(System. in);

System. out. print out("Quantity:");

double n = stdin. nextDouble();

System. out. println(n + " * " + n + " = " + n * n);

 

 

Ans:- general population static void main(String[] args)-method

double n = stdin. nextDouble();-variables

public, static, void, -keywords

stdin println-keyword

test -class

double-parameters

-

More than 7 000 students trust us to do their work
90% of customers place more than 5 orders with us
Special price $5 /page
PLACE AN ORDER
Check the price
for your assignment
FREE