You are on page 1of 9

Programming Language --> Java, Dotnet, PHP Database --> PLSQL [Oracle], TSL [MS Sql Server] Android

--> Basic Java a) b) c) d) e) f) g) h) i) Grading 25% on Written Exam 75% on Projects Advance Java Programming 1] J2EE --> Servlets 2] JSP 3] Basics EJB 4] Spring 5] Hibernate 6] Struts 7] JMS Java Conventions a) b) c) 1) 2) 3) t] Class Names should start with Capital Alphabets Method Names should start with small alphabets package names should start with small alphabets The source code file name can be any name. While compiling the source code name should be given [javac Swati.java] While running, the name of the class having the main should be given[java Tes with no .class suffixed Programming OOPs Basics Exception Multi Threading AWT [Abstract Window Toolkit] Event Handling IO JDBC Networking RMI

1) Variables 2) Static Non Static Methods 3) Constructors 4) this keyword -- current class 5) super keyword -- base or parent class 6) data types 7) Flow Controls 8) Operators 9) Order of Constructor Calling 10) Inner Classes 11) packages 12) Over Loading 13) Over Riding 14) Dynamic Binding 15) Abstract Classes 16) Interfaces Variable: Name given to a memory. Based on scope a) Class Variable b) Method Variable c) Instance Variable Static Class Variables -->

Non-Static Class Variable

-->

static --> associated with the class and hence no instance is needed non-static --> associated with the instance and instance is needed Constuctor v/s method a) b) c) d) Same Name No Return Type Automatically called when a instance i created initialize the class variables

Parameter v/s Argument 4 Categories of Data Types A] Integral byte 8 bits -128 to 127 short 16 bits int 32 Default long 64 Floating Point float 32 double 64 Default Textual char 16 unicode [can take all foreign languages] unsigned Logical boolean 1 bit [true or false]

B] C] D]

default of char is space and of boolean is false. Operators 1] Unary Plus Increment Decrement ~ Tild or Tilda [Bit wise Inversion Operator] ! [Boolean Complement] () [Type Cast] 2] Arithmetic [ + - / * % --> BODMAS ] 3] Shift [ << >>] 4] Bitwise [ & | ^] 5] Short Circut [ && ||] --> 6] Comparison [ instanceof, == .equals] --> return a boolean value 7] Ternary [ ( ) ? True : False] In Short Circuit it always checks for the LHS and depending on the value of the LHS it will decide to or not to check the RHS && if the LHS is false then the whole answer is false without checking RHS if the LHS is true then it will check the RHS and act like a normal & Flow Controls a) Loops [ for, while, do-while, for each, enhanced for loop] b) Selection Statement [if, if else, switch] c) Jump Statement [break, continue] switch --> byte, short, int or char as its parameters

Inner Classes a) b) c) Normal Inner Class Static Inner Class Inner class within a method [Best form of Encapsulation]

package: mapped to a folder in the file system and is used for grouping classes together. 4 visibility modifiers --> private, package access, protected, public private--> only in the class in which it is declared package access --> in all classes in the same package with or without inheritanc e protected --> like package access for classes in the same package but also visib le in another package if that class inherits it public --> available any where. Over Loading --> Same function name, but different type or order of parameters signature --> is used in Over Riding a) Access Modifier b) keyword c) Return Type d) Name e) Parameters f) throws exception to the rule of same signature is that;The overriding method cannot be less accessible than the over ridden method Dynamic Binding - Late Binding - Runtime Polymorphism - Dynamic Method Dispatch [The decision to call a method is taken at runtime]. Static methods cannot be ov erridden. Abstract classes: Interface --> What and Why is it needed? a) b) c) d) rface AWT 1) 2) 3) 4) 5) Login Application Login Applet BorderTest ChoiceTest ChatApplet IS-A relationship [parent child] --> abstract class Template and want all subclass to mandatorily adhere it --> Interface Default implementation is present in the Template --> abstract class A entity to be used by multiple entities [multiple inheritance] --> inte

3 difference between applet and application a) b) c) d) e) 1) 2) 3) 4] 5] browser v/s non browser java.applet v/s java.awt no main v/s main as the entry point embedded in HTML v/s stand alone over-ride paint v/s sop import java.applet.* extends Applet Step1] Remove Frame Step2] init Step3] No need to change

6] 7] 8] 9] 10]

Step4] add(l1)...... Step5] XX Step6] Not needed main --> not needed html file

6) MenuTest 7) Scroll Test 8) using setBounds --> in Login Application Event Handling --> a) import java.awt.event.*; b) implement the proper listener [different controls generate different events] c) override the methods in the interface Button --> ActionEvent --> ActionListener a) import java.awt.event.*; b) class LoginApplication1 implements ActionListener 5) b1.addActionListener( this);// this means the current class which is responsi ble for handling the event c) public void actionPerformed(ActionEvent e){ if (e.getSource()==b1){ String x = t1.getText(); String y=t2.getText(); System.out.println(x+" "+y); } else{ t1.setText(""); t2.setText(" "); } } 2] LoginApplet --> extends Applet implements ... 3] BorderTest --> on clicking the button --> label of the button to be appended to the TextArea --> append is only present in TextArea ta.setEnabled(false); public void actionPerformed(ActionEvent e){ Button b1 = (Button)e.getSource(); String s1 = b1.getLabel(); ta.append(s1 + "\n"); } 4] ChoiceTest --> when the user enters a name in the TF and clicks ADD, name sho uld be added to the Choice and when he selects some name from the choice and cli cks delete, it should be removed from choice. If the screen needs to be refreshed, we should call a) validate() b) repaint() --> first called update [clear the screen] and then it will call pa int 5] ChatApplet --> when the user types in the TF, he can either click ADD or pres s enter to take the text to the TA [getText(), setText(), append] 6] Move screens : Create an application having two buttons. on clicking the firs t, it will go to LoginApplication and on clicking the second it will open Choice Test new LoginApplication1(); f.dispose(); Exception Handling

What is an exception? Throwable Errors are conditons that an application should not catch, Exceptions are condit ions that an application should catch try, catch Exception Object --> a) Type of Exception b) Message c) Method in which it happened d) Java class name e) line number --> together this is called the stacktrace All checked exceptions should be in a try-catch block or else will generate a un reported exception at compile time. finally --> block will execute always, where a exception is handled or not. All closing statements for a file, connection or a socket should be present here. try{ int a = 10/0; }catch(Exception e){e.printStackTrace();} finally{System.out.println("Finally");} System.out.println("Finished"); try{ int a = 10/0; } finally{System.out.println("Finally");} System.out.println("Finished"); -------------------------------------------------------------------------------------------throw --> manually generating a User Defined Exception. throws --is written in the signature of a method informing the calling method th at an exception might be generated and they should take care of it. Product Developer --> throws End User -- try-catch a) b) AdjustmentListener --> adjustmentValue Changed FocusListener --> focusGained and focusLost

============================================================ Input Output JDBC Day 5 c) d) ItemListener Mouse Listener

Oracle Connectivity via Java --> JDBC --> Java Database Connectivity DSN --> Data Source Name Connectivity Driver --> Interface between Frond End and Backend 4 types--> a) JDBC - ODBC Bridge --< works only in Windows b) Native DB Driver --> specific to a particular Database and Product companies

cannot use this Driver c) Middleware Driver --< J2EE d) Thin Driver or Pure Java Driver ycpait [Server Name] --> username and password --> Connection String Steps in the DB Connect a) b) c) Load the Driver via DriverManager.registerDriver Create a Connection Create a Statement

classes111.jar file should be placed in jdk/jre/lib/ext Multi-Programming --> different applications running parallely Multi-Processing [parallel processing] --> single process running on multiple pr ocessors Multi-Tasking -> concurrent processes running within a program Multi-Threading --> smallest unit of a task having a definite start and end Threading --> java via Runnable Interface [ method called run] which will be the body of the thread Thread class internally implements the Runnable interface and overrides run in a n empty fasion. 2 ways of creating Threads [ because extends can be used only once] a) implements Runnable [preferred] b) extends Thread Thread Scheduler --> Pre-Emptive --> Only the highest priority thread can run Adv--> highest priority thread will always run first Dis-Adv --> Starvation Round Robin / Time Sliced --> all threads run for a fixed period of time Adv --> All threads will get atleast some time Dis-Adv --> Waiting time for priority thread + No Sequential Processing Register the Thread with the TS --> calling start method of the Thread Synchronization --> whenever a shared resource needs to be accessed by multiple threads, it should be always synchronized. WindowListener --> windowClosing --. X windowOpened --> first time windowClosed --> after closing windowIconified --> min window Deiconified --> max windowActivated --> gaining focus windowDeactivated --> losing focus Adapter classes --> are for those listeners having more than 1 event handler. wh en using Adapter, we will extend the adapter class and override on the method wh ich we want as the Adapter would have internally implemented the listener and ov erridden all the methods in a empty fashion. 3 ways of event handling a) listener b) adapter class --> extends WindowAdapter + only override window closing

c) Anonymous Inner Class --> neither extend nor implement first time: activated+opened min: Iconified + deactivated max: Deiconified +activated X: closing + closed JDBC --> CRUD IO - java.io.* --> reading or writing of Data Every class in the IO package has to have these 3 attributes Byte Stream Data Transfer 8 Class Inherits from Input / Output Stream Class Name ends with Stream word Input Stream read Low Level Stream Are always in direct touch with the source Character Stream 16 Reader/Writer Reader / Writer word Output Stream write High Level Stream Never directly contact the source Will always have another low level in its constructor

Dir List.java FileCopyRead.java MenuTest. java --> High Level Streams Collections Boxing --> Converting Value [Data Types] to Reference [Objects] int a = 10; Integer i = a; Unboxing --> Converting object to data type Integer i = new Integer(10); int b = i; Enumeration--> CR Annotation: Metadata written in the source code Collection : Set --> Unordered -- no duplicates-HashSet List--> Ordered -- can have duplicates -->ArrayList Map --> Key Value where both are objects -->HashMap or SortedMap For looping through a collection, we need a iterator or enumeration Networking

InetAddress --> IP Address of a system. [ DNS and Decimal] TCP/IP --> Connection Oriented - reliable UDP --> Connection Less -- unreliable 2 non-static methods --> getHostName() and getHostAddress(); 2 static methods which returns a InetAddress itself -->getLocalHost() & getByNam e(String) 2 classes in TCP / IP --> ServerSocket and Socket Client Socket[IP Address and Port No) InputStreamReader (System.in) BufferedReader (readline) PrintWriter [printing to the socket] One Way Client Chat Two Way Client Chat --> a) multi threaded --> extends Thread, call the start method in the constructor, override the run and have the while loop inside that. b) Inner class for both Client and Server Client Outerclass --> Mouth Piece Socket, ISR, BR, PW Server Ear Piece SS, Socket, ISR,BR Server ServerSocket Socket ISR BR

Inner class --> after the main but before closing the outer class --> Ear Piece Mouth Piece ISR [read from socket] ISR [read from console] BR BR PW PSVM create a instance of outer class create a instance of outer class IMP*** create a inner class instance inside the outer class constructor -----------------------------------------------------------------------------------------------------1 Entry point is client main [Client should extends Thread] 2 Constructor of client --> initialize S,ISR,BR,PW + start 3 Override Run --> while logic of reading from console and printing to socket 1 Entry point is server main [Server should extends Thread] 2 Constructor of server --> SS,S, ISR, BR + start 3 Override Run --> while logic of reading from socket and printing to console 1 Inner class for Client extends Thread 2 Constuctor of inner class --> initialize ISR[read from socket], BR + start 3 Override Run --> while logic of reading from socket and printing to console 1 Inner class of Server extends Thread 2 Constructor of inner class--> initialize ISR [read from console], BR, PW +star t 3 Override Run --> while logic of reading from console and printing to socket

You might also like