Computer Science : Class Libraries

Study concepts, example questions & explanations for Computer Science

varsity tutors app store varsity tutors android store

Example Questions

Example Question #1 : Class Libraries

Which of the following header statements allow you to omit using the std:: when using cout?

Possible Answers:

#include <standard>

#include  <cmath>

You don't need a header statement.

using namespace std;

#include <iostream>

Correct answer:

using namespace std;

Explanation:

You must put using namespace std; at the top of your file to avoid having to type std:: every time you use cout and cin.

Example Question #2 : Class Libraries

Which of the access modifiers don't work in Java?

Possible Answers:

final

abstract

static

delete

Correct answer:

delete

Explanation:

One of the benefits to Java is that there is garbage collection. So when data is disposed of its done automatically versus a language like C++ where you need to tell the program to delete dynamically allocated data.

Example Question #3 : Class Libraries

What line of code is needed to import in order to use Color in the following format Color.Blue, Color.RED, Color.White?

Possible Answers:

import java.util.Color;

 

import java.awt.Color;

import java.awt.*;

import java.io.Color;

Correct answer:

import java.awt.*;

Explanation:

If you were to use the following format Color.Red, Color.Blue, etc then the correct answer would have to be java.awt.*; While java.awt.Color; does fit the appropriate code, if you import that entire statement, you don't need to put Color.Red just Red and following. The other two import statements are just completely wrong.

Learning Tools by Varsity Tutors

Incompatible Browser

Please upgrade or download one of the following browsers to use Instant Tutoring: