Title | Advanced Java Lecture Notes 12-10 |
---|---|
Course | Advanced Java Programming |
Institution | Valencia College |
Pages | 4 |
File Size | 83.9 KB |
File Type | |
Total Downloads | 40 |
Total Views | 143 |
Lecture Notes from Advanced Java, Chapters 1-4...
Advanced Java: Lecture Notes 12/10/18
Generics are important to Java because they enable the creation of code that is o Type-safe o Reusable o Reliable
Can a primitive type be used as a type argument? o No, type argument must be object types
Show how to declare a class called FllghtSched that takes two generic parameters. o class FlightSched {
Can the wildcard argument be bounded? o Yes, a wild card can have either an upper or lower bound
Do type parameters exist at run time? o No, all type parameters are erased during compliation, and appropriate casts are substituted
All methods in an abstract class must be decalred as abstract methods o False
Invoking a subclass-only method through a subclass variable is not allowed o False
If a superclass declares an abstract method, a subclass must implement that method. o False
An object of a class that implements an interface may be thought of as an object of that interface type o True
An annotation is syntactically based on a/an: o Interface
A marker annotation is: o One that does not take any arguments.
An annotation can be applied only to methods. o False
@Override public String toStringQ { Return String.format("o/os: o/os o/os\no/os: o/os\no/os: %.2f\no/os: %.2f', "commission employee", firstName, lastName, "social security number", socialSecurityNumber, "gross sales", grosssales, "commission rate", commissionRate); } //end method toString o @Override annotation is used to indicate that method toString should override a superclass method.
What method is called when an applet first begins running? o init0
What method is called when an applet is removed from the system? o destroy()
Which method is invoked for an applet each time a browser's user leaves an HTML page on which the applet resides? o Stop
Every applet should extend class o Applet OR JApplet
Which of the followings can be used to execute a Java applet? o appletviewer or a browser
What method is invoked to draw on an applet o Paint
The HTML tags that we use to specify that an applet should be loaded into an applet container and executed. o ,
Multithreading is supported by the o Thread class and the Runnable interface
When creating a runnable object, why might you want to extend Thread rather than implement Runnable? o When you want to override one or more of Thread's methods other than run().
Show how to use joinO to wait for a thread object called MyThrd to end o MyThrd.joinQ;
Show how to set a thread called MyThrd to three levels above normal priority o MyThrd.setPriority(Thread.NORM_PRIORITY + 3);
Adding synchronized to a method allows only one thread at a time to use the method for any given object of its class. o True
The waitQ and notifyQ methods are used to perform o interthread communication
What method defined by Thread obtains the name of a thread? o getName()
What does isAliveQ return? o true if the invoking thread is still running OR false if the invoking thread has been terminated
Why can't you use suspend(), resume(), and stop() for new programs? o The three methods have been deprecated because they can cause serious run-time problems.
Exception UnknownHostException occurs when o a hostname indicated by a client cannot be resolved to an address.
Exception IOException occurs when o an input/output error occurs when closing a socket.
Many of Java's networking classes are contained in package o Java.net
An object of class ___ contains an IP address o lnetAddress
Class ____ binds the application to a port for datagram transmission o DatagramSocket
With stream sockets a process establishes a connection to another process o True
Statement objects return SQL query results as o ResultSet object
SQL keyword ____ is followed by the selection criteria that specify the rows to select in a query o WHERE
Merging rows from multiple database tables is called o joining tile tables
Drivermanager method getconnection is used to o obtain a connection to a database
A disconnected Rowset, caches the data of a ResultSet in memory o CachedRowSet...