Flashcards
212Jaba
Flashcards do conjunto (48)
- 1Whats an Object1 - An abstract thing
- 2Whats a class1 - A set of variables and methods that are encapsulated together
- 3What is an instanced Variable1 - A set of zero or more variables encapsulated with in a class
2 - Person lecturer; - 4What is a method1 - A block of code that is encapsulated with in a single class
2 - Int getName (){return name;} - 5What is an Instance1 - A realization of a class
2 - Get their own independent copy of all defined variables
3 - Person joe = New Person(); - 6What is a constructor1 - An optional method that is automatically called by the new operator upon instantiation of a class
2 - They do not have a defined return type
3 - Class Person{ Person (int anAge_{ age = anAge;} - 7What is an Actual parameter1 - The variable supplied by the caller
2 - if(joe.olderThan(18)
3 - 18 is an actual parameter - 8What is a formal parameter1 - Variable used with in the method
2 - boolean olderThan(int rating)
3 - Rating is the formal parameter - 9Is Java pass by value or reference1 - Pass by value
- 10What is an Object reference1 - Person p = New Person();
2 - p = pointer to the new object - 11What does the "this" keyword do1 - Returns an object reference to the instance which the current method is executing in
2 - Public class Person
int age
Person(int age){
this.age = age; - 12What are reference types1 - Are anything related to objects
2 - References to objects
3 - It is the referene that you are accessing or modifying - 13What are Value Types1 - It is the data itself that you are accessing or modifying
- 14Why do we use Inheritance1 - To promote reuse and extensibility
- 15What is Inheritance1 - Where onne class can be derived from or extend another to create a new class
2 - We use EXTENDS - 16What happens when we use extends1 - The instance variables and methods defined implicitly become part of the new class
2 - Those variable and methods can be accessed in the new class - 17Example of Inheritance..public class Lecturer extends Person{}
1 - All methods in the superclass become part of the new subclass - 18What do we mean by Inheritance is Transitive1 - If a class is a subclass of another. IT is also a subclass of that classes parent class.
2 - Class Mammal
3 - Person extends Mammal
4 - Lecturer extends Person
5 - Lecturer inherits instance variables and methods from Mammal and person - 19Inheritance Hierarchy1 - Can be mapped out using a tree with a Super class at the top.
2 - Anything extending is branched out to a leaf/node - 20What happens if we go up/down the tree1 - Up the tree is more abstract
2 - Down the tree is more specialist - 21What is SUPER DUPER LEMON DUPER REPORT ABUSE SYSTEM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1 - When we extend a class, we can create a new constructor for the new class or we can use the constructor of the super class
2 - Super allows us to use the constructor from the super class
3 - MUST BE THE FIRST THING IN CONSTRUCTOR!!!!!!!!!!!!!!!!!!!!!!!! - 22What is method Overriding1 - Used to change the behavior by replacing a method in the superclass
2 - - 23What is method overloading1- We can have more than one method with the same in the same class, as long it has different params.
- 24What is Polymorphism1 - To take many forms
2 - Provides backward compatitbility of a subclass with any code written for its superclass
3 - We use method overrloading and overriding for this - 25What is casting1 - Covert between types of object references
2 - Only if object is the same class or a subclass of the type you are casting to - 26What is an Abstract Class1 - classes which are not instantiated only extended.
- 27What is an abstract method1 - Similar to abstract classes
2 - Used if you know that method is needed. - 28What is an Interface1 - An abstract specification of 0> methods
2 - Cannot contain instance variables
3 - Cannot contain method implementation
4 - Clas can implement any number of interfaces - 29What is protection1 - Not letting people fiddle with my cogsLOL
2 - - 30What is a public class1 -Class that is available to everyone to see
- 31What is a protected class1 - Exposed to the class, package and the subclass
- 32What is a private class1 - Cant be seen by anyone other than the stuff inside THAT class.
- 33When do we use accessors1 - Getters
2 - Only use when you want the variable to be visible outside the class - 34When do we use mutators1 - Only if you want the variable to be mutable (change)
- 35What is the final keyword1 - A variable that you assign which is immutable. Doesnt change
2 - Classes which are final can never be sub classed
3 - Methods with final can never be changed using overriding - 36What are static variables1 - Variables which are unique to that class
2 - Variable accessible without the need of an instance - 37What are static methods1 - Methods that operate of instances
2 - Methods operate ob classes and do need the class to be instantiated - 38What are exceptions1 - A set of classes for supporting run time errors
2 - They are flow control primitives
3 - If an exception occurs, then it will run the exception handler - 39What is the try catch1 - Try surronds a block of code which may cause the exception
2 - Catch defines the code that is executed when the exception is raised - 40What is the finally keyword1 - Surronds the code that you want unconditionally executed after the try catch blocks no matter what
2 - - 41What is the Throw keyword1 - Where it throw an exception after it has been created
2 - Is followed by an instance of the exception
3 - Cannot throw multiple throw - 42What is the throws keyword1 - When you want to declare an exception
2 - throw after the method or class declaration.
3 - Can have multiple exceptions declared - 43What are Generics1 - To deal with type-safe objects
2 - Used when creating a specific instance of that item - 44What are Wildcard Types1 - Represents a wild card types
2 - = any type
3 - - float, int, double etc - 45Benefits and drawbacks of generics1 - Extensibility with type safety (+Ve)
2 - Runtime type erasure. purely compile time (-Ve) - 46What is a collection in Jaba1 - Used to store and manipulate a group of objects
- 47What are Iterators1 - Needing to interate over the contens
- 48What is a class factory1 - That you expect future class to be polymorphically compatible with
2 -
Informações
- Descrição
- FlashCards sobre 212Jaba, criado por Shez F em 16-05-2017.
- Criado por
- Shez F
- Visualizações
- 5
- Avaliação