Java Test 3 Practice Questions Chapter 6-7

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

object

A house is to a blue print as a(n)____ is to a class

False ( A reference to an object is required to invoke an objects methods.)

A primitive-type variable can be used to invoke a method.

import declaration

A(n) _____is not required if you always use a class's fully qualified class name

True

An import declaration is not required when one class in a package uses another in the same package.

default package

By default, classes that are compiled in the same directory are considered to be in the same package, known as the________

False

Can we compare int variable with a boolean variable?

True

Can we have multiple classes in same java file?

False

Can we have two public classes in one java file?

java.lang

Class String is a package ______

Field: Declared in a class, but not in the body of any of the class's method, and accessible to all methods of the class.

Difference between local variable and field. (Fields)

Local variable: declared in the body of a method and can be used only from the point at which it's declared through the end of the method declaration.

Difference between local variables and a field.(Local variable)

type, name

Each parameter must specify both a(n)_____ and a(n)_____

import isn't required if Scanner is always referred as java.util(fully qualified class name)

Explain how a program could use class Scanner without importing the class.

A field that represents an objects attributes.

Explain the purpose of an instance variable

These classes provide public methods to allow clients to set(assign values to) or get (obtain the values of) private instance variables.

Explain why a class might provide a set method and a get method for an instance variable.

True

Is an empty.java file a valid source file?

modifier

Keyword public is an access____

new

Keyword_____ request memory from the system to store an object, then calls the corresponding class's constructor to initialize the object

True

Objects are stored in the heap int p = new int (20); stored in heap because is an object.

False

Objects are stored on Stack

True

Primitive variables are stored on Stack ex: int j = 20;

false (Primitive-type variables are initialized by default. Each local variable must explicitly be assigned a value. )

Primitive-type local variables are initialized by default.

True

Reference-type instance variables are initialized by default to be value null.

False

Static functions can be accessed using null reference

False (Such variables are called local variables and can be sued only in the method in which they're declared.)

Variables declared in the body of a particular method are known as instance variables and can be used in all methods of the class.

True

Variables or methods declared with access modifier private are accessible only to methods of the class in which they're declared.

A class is a blue print from which individual objects are created. A class can contain fields and methods to describe the behavior of an object.

What is a class in java?

When compiler provides a constructor without parameters in any class that doesn't explicitly include a constructor. Instance variables are initialized to their default values

What is a default constructor? How are an object's instance variable initialized if a class has only a default constructor?

Request memory from the system to store an object, then calls the corresponding class's constructor to initialize the object.

What is the purpose of keyword new?

instance variable

When each object of a class maintains its own copy of an attribute, the field that represents the attribute is also known as a(n)________

Boolean

Which of the following is not a keyword in java?

Not assigned

Which of the following is not the default value of a local variable?

Depends upon the type of variable

Which of the following is the default value of an instance variable?

That's because classes System and String are part of the package, java.lang..

Why is every application allowed to use classes system and String without first importing them?


संबंधित स्टडी सेट्स

Quiz 11 Information Security Fundamentals

View Set

Internet Basics: Internet Basics- Assessment VII

View Set

Review Questions Network+ Module 3

View Set

Working with the Command Line Interface

View Set

BLAW, CH. 10: Nature and classification

View Set

AP Psychology Modules 74-80 Vocabulary

View Set