What is the output of the code snippet

Assignment Help Electrical Engineering
Reference no: EM13230375

1. When organizing a program into three files (main, class implementation, and class header), which is not a .cpp file?

main

none are .cpp

class header

class implementation

 

2. Creating classes with private data members is an example of:

encapsulation

polymorphism

inheritance

abstraction

 

3. Given the following class definition and lines of code, Line 1 in main is a call to what?

class Distance

{

private:

int feet;

double inches;

public:

Distance( );

Distance(int initFt, double initIn);

void setFeet(int feetIn);

void setInches(double inchesIn);

int getFeet() const;

double getInches( ) const;

};

int main( )

{

Distance d1; //Line 1

const int MAX = 100; //Line 2

Distance list[MAX]; //Line 3

Distance d2(1, 2.3); //Line 4

Distance * pDist; //Line 5

d1.feet = 5; //Line 6

// etc. - assume the remaining code is correct

}

The 0-argument Distance constructor

The 2-argument, int, double, Distance constructor

The 2-argument, double, int, Distance constructor

The 1-argument, int, Distance constructor

 

4. How many parameters are required to overload the pre-increment operator for a class as a member function?

none

1

2

no limit

 

5. Variables defined to be of a user-declared class are referred to as:

attributes

member variables

primitive variables

objects

 

6. What is the output of the following code snippet?

int *list = new int[5];

int *ptr;

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

list [i] = i + 1;

ptr = list;

delete [ ] list;

cout << *ptr;

1

address of list

address of ptr

error - ptr references memory which no longer belongs to the program

 

7. Given the following definitions, select the statement that is illegal.

int * iptr;

double * dptr;

int j = 10;

double d = 10.0;

iptr = &j;

dptr = &d;

iptr = 0;

dptr = &j;

 

8. Given a class called Employee and the following definitions and statements:

void myFunction (Employee * eptr);

Employee emp;

Which of the following statements correctly calls the function passing in the address of the data array?

myFunction(emp);

myFunction(&emp);

myFunction(*emp);

myFunction(**emp);

 

9. What does the following Java code do?

JPanel pane = new JPanel( );

pane.setLayout( new gridLayout(2, 3) );

Creates a panel which will organize its components into 5 distinct cells.

Creates a panel which displays a grid containing the numbers 2 and 3.

Creates a panel which will organize its components into two rows of three columns.

None of the above

 

10. Which of the following provides the basic attributes and behaviors of a Java window - a title bar at the top of the window and buttons to minimize, maximize, and close the window?

JLabel

JFrame

JSwing

JWindowsControl

 

11. Which Java interface would you need to implement in order to handle events, such as key pressed or key released events?

KeyListener interface

KeyStroke interface

KeyEvent interface

This information is not available in a Java program.

 

12. In order to be able to use the JFrame, JPanel, and JButton classes, you must:

include the Swing header file ("Swing.h")

import the Swing class

import javax.Swing.*;

import java.awt.*;

 

13. Which of the following Java statements creates an object of a ButtonHandler class (which implements the ItemListener interface) and associates it with a JRadioButton object called buttonOne?

buttonOne.addItemListener(ButtonHandler( ));

buttonOne.addItemListener(new ButtonHandler());

buttonOne.+= new ButtonHandler( );

buttonOne.addEventHandlerr(new ButtonHandler( ));

 

14. What can you say about the following Java class?

Public class MyApp extends JFrame ( ...)

MyApp is a Java application.

MyApp implements the JFrame interface.

MyApp inherits from the JFrame class.

MyApp has a nested inner class called JFrame.

Reference no: EM13230375

Questions Cloud

Design controller to operate separate sets of traffic light : The configuration is shown in Figure 6.5. Use six LEDs as shown in Table 6.1 to represent the outputs. The Time in This State can be met in several ways. One method is to use a debounced switch as input, another to input a 1 Hz clock.
Set up and list the linear program : Set up and list the linear program that can maximize the revenue for this case.
What is the yield to maturity for an swh corporation bond : What is the yield to maturity for an SWH Corporation bond on January 1, 2006 if the market price of the bond on that date is $1,035?
What qualitative measure approach will most likely : If a marketing research firm has decided to photograph people within the lobby of a movie theater over a two- to three-day period, what qualitative measure approach will most likely be used to accomplish this task?
What is the output of the code snippet : Which of the following provides the basic attributes and behaviors of a Java window - a title bar at the top of the window and buttons to minimize, maximize, and close the window JLabel JFrame JSwing
Explain what light intensity in wm2 : An ocean diver experiences a light intensity (origination from the sun) of 452.6 W/m2 at a depth of 6.15 meters from the surface of the ocean. At a depth of 25.6 meters, the light intensity is 336.5 W/m2. What light intensity, in W/m2, will the di..
Explain the cultural values of the organisation : Imagine yourself in a situation of being encouraged to inflate your expense account. Do you think your choice would be most affected by your individual moral development or by the cultural values of the organisation for which you work?
Explain the hardy-weinberg equilibrium : A hippopopulation has a locus with 2 alleles, one fast swimmer and the other slow swimmer, If the population is in Hardy-Weinbergequilibrium, what is the frequency of the heterozygous genotypein the population
Compute the average induced voltage : Calculate the average induced voltage between the tips of the wings of an airplane flying 10,000m above West Haven at a speed of 1080 km/h. The wingspan of the airplane is 36.6 m, the Earth's magnetic field in West Haven is 5.5×10-5 T and the dip ..

Reviews

Write a Review

Electrical Engineering Questions & Answers

  Determine what is the average velocity of an electron

average velocity of v meters/second. If the concentration of free electrons is 10^{29} electrons per cubic meter and if they are uniformly dispersed throughout the wire, then what is the average velocity of an electron

  What are the values of parity bits for the first messages

There are two four bit messages, 1010 and 1110. The first one is appended with an odd parity bit, the second one with an even parity bit. What are the values of the parity bits for the first and second messages respectively.

  A circuit contains two devices that are connected

A circuit contains two devices that are connected in parallel. If the resistances of one of these devices is 12ohms and the resistance

  Why sinusoidal wave is chosen for ac fundamentals

why sinusoidal wave is chosen for AC fundamentals rather than a simple curve such as square or triangular wave?

  Will the breaker likely be tripped

Calculate current flow and describe its probable path. Will the breaker likely be tripped? Is there a risk of electrocution? If so what factors contribute to the risk?

  Explain bisection-false position and newton raphson methods

You deposit 10% of your annual salary at the each of each year in a retirement account. F= Future worth A1= first annual deposit n=number of years g=geometric gradient F=A1(1-(1+g)^n(1+i)^-n/(i-g))(1+i)^n use Matlab to graph the function.

  Define power systems theory definitions and formulas

Power Systems Theory Definitions and Formulas, Define, (a) The fault level of a system or unit in a system, (b) base MVA

  What is the signal-to-noise ratio of the spread signal

Suppose that a voice signal normally occupies 30 kHz of bandwidth and has a signal-to-noise ratio of 20 dB. Spread-spectrum techniques are used to increase its bandwidth to 2 MHz. (a) What is the signal-to-noise ratio of the spread signal

  Find the transfer function and resolution

find the transfer function and resolution for a 10-turn, 4.7k potentiometer with 3450 degrees of rotation and a 0 to 5 volt output. calculate the resolution in ohms per volt

  Find the equivalent e-field and the implied flux

The solar constant at Earth orbit (1 AU = 1 Astronomical Unit - Sun-Earth distance) is ~1400 Watts/m2. Assuming that this Poynting flux magnitude can be associated with a single E- and Hfield (i.e., E × H ),

  Implement the relative addressing mode

Write an optimal sequence of control microinstruction

  Define maximum number and the geometric mean

I started writing a program and need help. I need to be able to enter up to 15 numbers and output the minimum number, maximum number and the geometric mean.

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