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

  Calculate pmos device to acheive symmetric propagation delay

Calculate the PMOS device with to acheive symmetric propagation delays in an inverter (tPLH = tPHL). Use Wn=450nm Ln =300nm and Lp=300nm and solve for Wp. So I think by some ratio I can find what Wp should be, maybe something like Wn/Ln=Wn/Lp

  Define the angle of departure is defined

The angle of departure is defined as 180 degrees plus the phase angle of GH computed at the complex pole, but ignoring the contribution of that particular pole.

  What is the correspoding carrier- to - noise ratio

An AM receiver, operating with a sinusoidal modulating signal and 80 percent modulation, has an output signal-to-noise ratio of 30 dB. a) What is the correspoding carrier- to - noise ratio

  Explain using diagram

If L=0.0053nH, C=15µF find the operating frequency of series LC circuit. What factors decides capacitance? Explain using diagram.

  Define a discrete-time linear time-invariant system

Consider a discrete-time linear time-invariant system with impulse response h[n]. If the input x[n] is a periodic sequence with period N (i.e., if x[n]=x[n+N]), show that the output y[n] is also periodic sequence with period N.

  Draw the gate-level diagram

Write the logic equation for Y in terms of A,B,C that solves this problem, and draw the gate-level diagram.

  What range of k that makes the impulse response to zero

In the difference equation below K is a real number greater than 0. y[n) = x[n] + Ky[n] A) (2pt)Find the range of values of K that makes the impulse response grow without bound. B)

  Find the complex voltage gain of the amplifier

input voltage to an amplifier is: Vi(t)=0.1*cons(2000*pi*t+30) and the output voltage is: Vo(t)=10*sin(2000*pi*t+15) Find the complex voltage gain of the amplifier at f = 1kHz and express the magnitude of the gain in decibels.

  Compute the amount of time required to deliver

Compute the amount of time required to deliver 10 frames to the receiver with stop-and-wait flow control. Assume that all frames and ACKs are received correctly.

  Define a baseband sine wave signal with frequency

A baseband sine wave signal with frequency 4.0 kHz is modulated onto a carrier at 1.050 MHz using DSB-LC AM. What are the frequencies of the sidebands of the RF signal?

  Calculate the probability that the magnitude of the voltage

(b) This voltage is measured using a defective voltmeter, which always indicates a lower reading than the actual value. Suppose the voltmeter reading is 2.5*10^(-4). Calculate the probability that the error is not more than 0.5 *10^(-4).

  Describe the charge diffusion and drift in a pn junction

Describe the charge diffusion and drift in a PN junction, without and then with an applied voltage

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