Which of the following provides the basic attributes and


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.

Request for Solution File

Ask an Expert for Answer!!
Electrical Engineering: Which of the following provides the basic attributes and
Reference No:- TGS0566859

Expected delivery within 24 Hours