CSE205 Cheat Sheet Test1

CSE205 Cheat Sheet Test1 - 1)A java application always...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1)A java application always contains a single method, this method is called? Give the signature of this method. main public static void main(String[] args) 2)How is data given to this parameter? Through a command line interface. For example: java someCompiledClass data 3)Single line comments are preceded by what identifier? // 4)Multiple line comments are inclosed by which identifiers? /* */ 5)Identifiers can only begin with? Letters, underscores, dollar sign 6)Which of these are not key words? Abstract Boolean continue double extends false go hash instanceof new package parent short synchronized transient try volatile while go hash parent 7)Is Java an Functional Language, Procedural Language, Object-Oriented Language, or Logic Language? Object- Oriented 8)What does API stand for? Application Programmer Interface 9)What needs to be done to use the scanner class? import java.util.Scanner; 10)How would you print out “Hello World”? System.out.println(“Hello World”); 11)What’s the difference between println, and print. println ends with a line break 12)What is Encapsulation? 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 13)What are the three visibility modifiers, and what is their scope? 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. 14)What is the purpose of toString()? The purpose is to give a human readable representation of the object. 15)What is an accessor method? An accessor method can be defined to access private variable in the class since private data cannot be accessed from outside of the class. 16)What is mutator method? A mutator method can be defined to modify private variable in the class. 17)What is a constructor? A constructor is a special method that is used to create a new object. 18)Define a constructor with two parameters int x, y for the class Point. public Point(int x, int y){ this.x = x; this.y = y;} 19)Which method signatures would give an error if all methods were defined in a single class? 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){ … } 20)What is the difference between an instance variable, and a local variable. instance variables are global to all instance methods of the class, local variables are only visible to the method scope in which its defined. 21)The
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/11/2008 for the course CSE 205 taught by Professor Matasu during the Spring '08 term at ASU.

Page1 / 3

CSE205 Cheat Sheet Test1 - 1)A java application always...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online