Você está na página 1de 7

oops concepts ------------1.runtime polymorphism is also called as dynamic binding. 2.dynamic method dispatch = dynamic binding 3.

marker interfaces in java are java.io.serializable and cloneable.these interfaces do not declare any reqd methods but signify their compatibility with certain operations. 4.interface methods can be marked as public and abstract 5.interface may have member variables but not instance variables. 6.A class cannot be both abstract and final ? 7."this" keyword cannot be used by static methods 8.private methods and fields are not visible to subclasses and are not inherited by subclasses. 9.static methods = class methods 10.iterator is an interface implemented a different way for every collection 11.list iterator allows us to access a collection forward or backward direction and let us modify an element. 12.the 3 implementations of list interface: 1.ArrayList 2.Vector 3.LinkedList 13. java platform has 2 components.they are 1.java VM 2.java API 14.objects define their interaction with the outside world through the methods that they expose. 15.types of variables 1.instance variables(non-static fields)=member variables 2.class variables(static fields) 3.local variables

4.parameters.

primitive datatypes -----------------byte,short,int,long,float,double

->do not use float and double for currencies.use java.math.bigdecimal class. ->String objects are immutable, which means that once created, their values cannot be changed ->The prefix 0 indicates octal, whereas 0x indicates hexadecimal. ex:int hexVal = 0x1a;//the number 26 in hexadecimal. -->Local variables store temporary state inside a method. Parameters are variables that provide extra information to a method ->An array is a container object that holds a fixed number of values of a single type

->arithmetic operators are +,-,*,/,%(remainder operator) ->unary operators are +,-,++,--,! + Unary plus operator; indicates positive value (numbers are positive without this, however) Unary minus operator; negates an expression

++ Increment operator; increments a value by 1 -- Decrement operator; decrements a value by 1 ! Logical complement operator; inverts the value of a boolean

->type comparision operator:instanceof The instanceof operator compares an object to a specified type. You can use it to test if an object is an instance of a class, an instance of a subclass, or an instance of a class that implements a particular interface.

-->Access modifiers restrict the access to a class or a field inside a class. -->perform constructors test by giving same number of parameters and types??

--> Parameters refers to the list of variables in a method declaration. Arguments are the actual values that are passed in when the method is invoked. When you invoke a method, the arguments used must match the declaration's parameters in type and order.

-->Note: The Java programming language doesn't let you pass methods into methods. But you can pass an object into a method and then invoke the object's methods. --> passing info to a method or a constructor ?? creating objects ---------------it has 3 parts namely: 1.declaration 2.instantiation 3.initialization: The new operator is followed by a call to a constructor, which initializes the new object.

ex:->Point originOne = new Point(22,28);

-->subclass constructor invokes the super class no-argument constructor.if it's not there then compiler complains. -->This technique, called covariant return type, means that the return type is allowed to vary in the same direction as the subclass. -->Note: You also can use interface names as return types. In this case, the object returned must implement the specified interface.

using "this" with a constructor -------------------------------->explicit constructor invocation:calling another constructor from within one constructor using "this" keyword. ex:public Rectangle() { this(0, 0, 0, 0); } public Rectangle(int width, int height) { this(0, 0, width, height); } public Rectangle(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; }

-->if this is the case,the invocation of another constructor shud be the first line.

Interfaces ----------->An interface defines a protocol of communication between two objects.

-->pls refer to this link for latest j2ee:E:\deepak\adv_java\slides_infy\java\j2ee\Slides

-->sattnani@gmail.com

I/O STREAMS ------------------------------------------->file I/O byte streams are FileInputStream and FileOutputStream

-->Byte streams should only be used for the most primitive I/O

-->character stream classes are descendants of java.io.Reader and writer

-->character stream classes tht specialise in I/O are FileReader and FileWriter

-->character streams that use byte streams Line oriented I/O


Buffered Reader and PrintWriter are the classes involved in this

Scanning
scanning means breaking input into tokens and then translating them into their datatype. by default, it uses white spaces to separate tokens. Formatting printwriter-a character stream class and printstream-a byte stream class responsible for formatting of data. system.out and system.err are printstream objects. If we want formatted output then printwriter needs to be invoked I/O from command Line
y y

It involves standard streams and consoles An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes them into characters using a specified charset. The charset that it uses may be specified by name or may be given explicitly, or the platform's default charset may be accepted.

DataStreams
y y

Support binary I/O of primitive data types (Boolean,byte,short,long,float,char and double) and string data types. Datainputstream and dataoutputstream are the two classes used for this which implement datainput and dataoutput interface.

DataStreams uses one very bad programming technique: it uses floating point numbers to represent monetary values. In general, floating point is bad for precise values. It's particularly bad for decimal fractions, because common values (such as 0.1) do not have a binary representation. The correct type to use for currency is java.math.BigDecimal

ObjectStreams
y y

Object stream classes are ObjectInputStream and ObjectOutputStream Object stream consists of mixture of primitive types and objects.

Processes and threads:


y y

Threads exist within a process. But from the application programmer's point of view, you start with just one thread, called the main thread. This thread has the ability to create additional threads

Synchronization
y y y y

It is a tool used to prevent thread interference and memory inconsistency errors. Usage of volatile variables reduce memory consistency errors Atomic Access A concurrent application's ability to execute in a timely manner is known as its liveness

Set Interface
y y y y y

Implementations are hashset, treeset and linkedhashset . Hashset dont guarantee any order. Methods used for bulk operation in set are addall(union),retainall(intersection),containsall(subset),removeall Hashset internally uses hashtable to store its elements. Inorder to get iterator on any set we use object.iterator ().

List interface
y y y

Implementations are arraylist,linkedlist . Also, vector has been retrofitted to implement list. It has 2 iterators. They are iterator which is normal and listiterator which traverses the list in both directions and allows manipulations like removal and additions of elements Number of indexes is n+1 for n elements in list.

Queue interface
y y y y

Bounded queues which restrict the number of elements it hold. Linked list is a queue implementation which allows null elements. But in general, queue doesnt allow nulls. Priority queue is also an implementation of queue. Need to look into it as I didnt understand properly

Map interface

of the interface, as discussed later in this section. Map allows you to iterate over keys, values, or key-value pairs; Hashtable does not provide the third option.

Map provides Collection views instead of direct support for iteration via Enumeration objects. Collection views greatly enhance the expressiveness

y
y

Map

provides a safe way to remove entries in the midst of iteration; Hashtable did

not.
Hashmap doesnt order elements where as Treemap arranges keys in alphabetical order and linkedhashmap arranges the keys in the order of the input.

Below is the link for understanding of anonymous inner classes which are used in event handler interfaces in swings.

http://www.tek-tips.com/faqs.cfm?fid=1849

Você também pode gostar