Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 6 pages
Exam (elaborations)

CSE 205 Exam 1 Questions And Answers With Latest Study Solutions

Document preview thumbnail
Preview 2 out of 6 pages

CSE 205 Exam 1 Questions And Answers With Latest Study Solutions A java application always contains a single method, this method is called? Give the signature of this method. ANS main public static void main(String[] args) How is data given to this parameter? ANS Through a command line interface. For example: java someCompiledClass data Identifiers can only begin with? ANS Letters, underscores, dollar sign Is Java a Functional Language, Procedural Language, Object-Oriented Language, or Logic Language? ANS Object-Oriented What does API stand for? ANS Application Programmer Interface What needs to be done to use the scanner class? ANS import .Scanner; What's the difference between println, and print ANS println ends with a line break What is Encapsulation? ANS The hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed. The variables contained in an object should be modified only within the object What are the three visibility modifiers and what is their scope? ANS public: can be accessed from anywhere private: can only be accessed from inside the class protected: the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package. What is the purpose of toString()? ANS The purpose is to give a readable representation of the object. What is an accessor method? ANS An accessor method can be defined to access private variable in the class since private data cannot be accessed from outside of the class. What is mutator method? ANS A mutator method can be defined to modify private variable in the class. What is a constructor? ANS A constructor is a special method that is used to create a new object. Define a constructor with two parameters int x, y for the class Point. ANS public Point(int x, int y){ this.x = x; this.y = y;} Which method signatures would give an error if all methods were defined in a single class? ANS public int calc(int num1, int num2){ ... } public double calc(int num1, int num2){ ...} // differing return type is not enough,

Content preview

CSE 205 Exam 1 Questions And Answers With Latest
Study Solutions
A java application always contains a single method, this method is called? Give the

signature of this method. ANS main

public static void main(String[] args)



How is data given to this parameter? ANS Through a command line interface. For example: java
someCompiledClass data



Identifiers can only begin with? ANS Letters, underscores, dollar sign



Is Java a Functional Language, Procedural Language, Object-Oriented Language, or

Logic Language? ANS Object-Oriented



What does API stand for? ANS Application Programmer Interface



What needs to be done to use the scanner class? ANS import java.util.Scanner;



What's the difference between println, and print ANS println ends with a line break



What is Encapsulation? ANS The hiding of design decisions in a computer program that are most likely to

change, thus protecting other parts of the program from change if the design

decision is changed.
The variables contained in an object should be modified only within the object



What are the three visibility modifiers and what is their scope? ANS public: can be accessed from
anywhere
private: can only be accessed from inside the class

protected: the member can only be accessed within its own package (as with
package-private) and, in addition, by a subclass of its class in another package.

, What is the purpose of toString()? ANS The purpose is to give a readable representation of the object.



What is an accessor method? ANS An accessor method can be defined to access private variable in the
class

since private data cannot be accessed from outside of the class.



What is mutator method? ANS A mutator method can be defined to modify private variable in the class.



What is a constructor? ANS A constructor is a special method that is used to create a new object.



Define a constructor with two parameters int x, y for the class Point. ANS public Point(int x, int y){ this.x
= x; this.y = y;}


Which method signatures would give an error if all methods were defined in a single

class? ANS public int calc(int num1, int num2){ ... }

public double calc(int num1, int num2){ ...}
// differing return type is not enough, must differ in parameter types
and/or //number of parameters
public int calc(double num1, int num2){ ... }

public int calc(int num3, int num4){ ... }
// differs only in parameter name, must differ in parameter types and/or
//number of parameters
public int calc(int num1, int num2, int num3){ ... }



What is the difference between an instance variable, and a local variable? ANS instance variables are
global to all instance methods of the class, local variables are
only visible to the method scope in which its defined.



The this reference refers to the instance of the object. ANS instance

Document information

Uploaded on
April 16, 2025
Number of pages
6
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$13.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Nipsey
4.1
(377)
Sold
2117
Followers
1529
Items
15181
Last sold
3 days ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions