Featured

    Featured Posts

ADVANCE JAVA MAY 2015 Paper Code CSE-404-E

ADVANCE JAVA
May 2010
Paper Code: CSE-404-E

Q.1. How object oriented programming language concepts are better than structured programming ? Explain inheritance with example.
Ans :  Object-oriented programming(OOP) is a programming paradigm using "objects"- data structures consisting of data fields and methods together with their interactions - to design applications and computer programs.  Programming techniques may include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance.
        Object Oriented Programming(OOP) approache binds the dat and the functions that operate on that data into a single entity.  Such as entity is called an object.  Functions of an object can only access its data.  You can't access the data directly.  For example, if you want to read a data item in an object, you call a member function in the object, it will read the data item and return the value to you.  This secures data from any changes from outside.  Thus, OOP gives more emphasis on data.
        A C++ program typically consists of a number of objects which communicate with each other by calling one another's member functions.  Calling an object's member functions is also referred to as sending a message to the object.  The organization of a C++ program is shown in fig.

figure here--------

     Objects are independent of each other.  They are responsible for managing their own state and offering services to other objects.  Therefore, new objects can be easily added whenever necessary.
OOP have the following features.
  • OOP is more data oriented.
  • Programs are made up of objects which model real-world entities.
  • Data and Functions are binded together in an object.
  • Data security exists.
  • Objects communicate through functions.
  • Objects communicate through functions.
  • Addition of new data and function(i.e. object) is easy.
  • OOP follows bottom-up approach.


Ineritace :  Inheritance is one of the most important and useful feature of object-oriented programming.  There is a main class, called base class or super class, from which a new class id derived, called derived class or sub class.  Base class is also called parent class and the derived class is called child class.  Inheritance provides a mechanism for deriving new classes from existing ones.  In OOP, ther are several type of mechanisms:
  1. Single Inheritance: In this type of inheritance, a single sub class is derived from a single base class.
  2. Multiple Inheritance: In Multiple Inheritance, there is more than one base class from which the child class is derived.  This results in the duplication of data with the derived class.  Java does not directly support multiple inheritance.  This is because different classes may have different variables with same name that may be cotradicted and can cause confusions in JVM, thus resulting in errors.  We can extend one class only to avoid ambiguity problem with JVM.  In interface we have to define the functions.
  3. Multilevel Inheritance: In this inheritance, a class derives another class, and from the derived class, another sub class is derived.
  4. Hybrid Inheritance: There may occur situations where we need to apply two or more type of inheritance in the design of a program.  For each cases, hybrid inheritance is used.


Q.2. Explain the method of making URL connections.  Also explain how E-mails are sent.
Ans. Methods of URL Connection : A framework is provided by Java, using java.net package through several interfaces, classes, and abstract classes for handling URL(Uniform Resource Locator).  Using this framework, we can easily create sum function of web browser and can be embedded in an application.
       Before discussing the concept in-depth let's  have a description about two important classes is given below :
     (i)  Class URI : The term URI stands for Uniform Resource Identifier.  It create an instance of URL, and those are used to parse the string, and also providing various methods.  Every URL, is a URI, but not every URI, is a URL.
       On the base of conceptual difference between URIs and URLs, two different classes are given with their characteristics and functionalities.
     (ii) Class URL : Without URL, browser cannot make out the information about web.  URL identifies a resource anywhere on the Internet.  The introduction or URLs came up with WWW.
Web is a collection of protocols and different file formats.

Table: Methods of Java-net.URL class----

     (iii) Class URLConnection : The class URLConnection gives some additional information about web resource.  The class provides some methods by which you can send the request to server.  The class is actually abstract.  There is only constructor to create instance of URLConnection.
      URLConnection(URL urlString) creates a new URLConnection object for the URL urlString.  This constructor can be called only by a subclass of the URLConnection class; and subclass will gives the implementations of the various URLConnection methods for a specific protocol.
Example :
URL http_url = new URL("http://www.posthatke.com") ;
URLConnection urlc = new URL Connection(fttp_url ) ;
There is another way to create an instance of URL Connection, by invoking the openConnection() method of URL class, that return an object of URLConnection
Example :
URL http_url = new URL( "http//www.posthatke.com") ;
URLConnection urlc = http_url.openconnection() ;

Table : Method of java.net.URLConnection class

E-Mail server : A socket will be created, connect to port 25, which is SMTP port number.  Simple mail transfer Protocol describes the format in which e-mail message will be sent.  In UNIX OS, sendmail daemon was already implemented to support this features.




Example :
import Java.io.BufferedReader;
import Java.io.FileReader;
import Java.io.IOException;
import Java.io.InputStream;
import Java.io.InputStreamReader;
import Java.io.OutputStream;
import Java.io.OutputStreamWriter;
import Java.io.PrintWriter;
import Java.net.InetAddress;
import Java.net.Socket;
import Java.net.UnknownHostException;
public class SMTPDemo  {
public static void main (String args[] throws IOException, UnknownHostException  {
String msgFile = "file.txt";
String from = "java2s@java2s.com";
String to = "yourEmail@yourServer.com";
String mailHost = "yourHost";
SMTP mail = new SMTP(mailHost);
if(mail != null) {
if (mail.send(new FileReader (msgFile), from, to))    {
System.out.println("Mail sent.");
} else  {
System.out.println("Connect to SMTP sever failed !");
}
}
System.out.pritnln("Done");
}
static class SMTP   {
private final static int SMTP_PORT = 25;
Inetdderess mailHost;
Inetddress localHost;
BufferedReader in;
Public SMTP (String host) throws UnknownHostException  {
mailHost = InetAddress.getByName (host);
localHost = InetAddress.getLocalHost ( );
System.out.println("mailhost = "+ mailHost );
System.out.println("localhost = "+ localHost);
System.out.println("SMTP construtor done\n");
}
public boolean send (FileReader msgFileReader, String from, String to ) throws IOException   {
Socket smtpPipe;
InputStream inn;
OutputStream outt;
BufferedReader msg;
msg = new BufferedReader(msgFileReader);
smtpPipe = new Socket(mailHost, SMTP_PORT);
if (smtpPipe == null)  {
return false; }
inn = smtpPipe.getInputStream( );
outt = smtpPipe.getOutputStream( );
in = new BufferedReader(new InputStreamReader(inn));
out = new PrintWriter(new OutputStreamWriter(outt), true);
if (inn = = null \\ out= = null) {
System.out.println("Failed to open streams to socket.");
return false;
}
StringinitialID = in.read.Line( );
System,out.println(initialID);
System.out.println("HELO " + localhost.getHostName( ));
out.println("HELO " + localhost.getHostName( ));
String welcome = in.readLine ( );
System.out.println(welcome);
System.out.println("MAIL From:<" + from + ">");
out.println("MAIL From:<" + from + ">");
String senderOK = in.readLine( );
System.out.println(senderOK);
System,out.println("RCPT TO:<" + to + ">");
out.println("RCPT TO:<" + to + ">");
String RecipientOK = in.readLine( );
System.out.println(recipientOK);
System.out.println("DATA");
out.println("DATA");
String line;
While((line = msg.readLine ( )) != null )  {
out.println(line);
}
System.out.println(".");
out.println(".");
String acceptedOK = in.readLine( );
System.out.println(acceptedOK);
System.out.println("QUIT");
out.println("QUIT");
return true;
     }
   }
}


Q.3. Explain the following networking concepts :
(i) Advanced connection management
(ii) Metadata.
Ans. (i) Advanced Connection Manangement : Networking means transmitting data from one device to another device on the network, but both must use the same protocol for transmission.  There is an array of stack, called protocol stack, that involves everything from giving the data to physical device by converting that in  voltage pulse to delivering data streams to applications for which it was destined to.

Fig : Stack of layer

     Each layer provides an abstraction  and dedicated to a specific fix set of job.  The intermediate layers also work as an interface between its upward and downward layer, first and then the last.
     Each layer communicates only with its immediate above and below layers.  Encapsulation and decapsulation are two mechanism, that embed each layer's packets into the immediately below layer packet, and reverse the process at the data moves up at the receiving machine, respectively.
     As internet is a bunch of networks of different types of environments.  The internet is exclusively the worldwide set of connections of TCP/IP networks which use IP address and protocols under the

Q.5. What are Java swing ? How to implement a tree using Java swing.    (20)
 Ans. Java swing : Swing is a set of packages that are built on top of AWT which provides a large number of inbuilt predefined classes.
       Swing class provides a large set of components such as toolbars, progressbar, text fields and timers.  Swings provides a large set of built-in controls such as tree, image buttons, sliders, tabbed panes, toolbars, tables, color choosers etc.
       Swing provides several UI components of which, few are:
  • JOptionPane : Mkes it easy to pop up a standard dialog box.
  • JPanel : A generic lightweight container.
  • JpasswordField : It allows the editing of a line of text where the user views some special characters in place of original characters.
  • JPopupMenu : It provides a pop-up menu.
  • JProgressBar : It is a component that displays an integer value within an interval.
  • JRadioButton : A radio button cn be selected or deselected displaying its state.
  • JScrollBar : It gives an implementation of the scrollbar.
  • JSeparator : It provides a menu separator.
  • JSlider : It is a component that lets the user select a value by sliding knob.
  • JTable : It presents the data in a two-dimensional format.
Program to implement a tree using Java swing.

import Java.awt.*;
import Javax.swing.*;
import Javax.swing.tree.*;
import Java.awt.event.*;
public class SimpleTree extends JFrame {
public static void main(string[] args) {
new simple tree();
public SimpleTree() {
super("Creating a Simple JTree") ;
WindowUtilities.setNativeLookAndFeel() ;
addWindowListener(new ExitListener()) ;
Container content = getContentPane() ;
Object[] hierarchy = {"1. CHAPTER 1",
new Object[] { "1.1 INTRODUCTION TO JAVA",
"1.1.1 History of JAVA",
"1.1.2 JAVA and Internet",
"1.1.3 JAVA Virtual Machine",
"1.1.4 JAVA's Magic : The Byte Code",
"1.1.5 Features of JAVA',
"1.1.6 JAVA Environment"},
new Object[]{ "1.2 DATA TYPES & OPERATORS"},
new Object[] { "1.3 ARRAYS",
"1.3.1 Declaration of Array Variables",
"1.3.2 Array Construction",
"1.3.3 Initialization of Array",
"1.3.4 Array Access",
"1.3.5 Arrays of Characters"},
new Object[] { "1.4 CONTROL STATEMENTS"},
new Object[] { "1.5 A SAMPLE PROGRAM IN JAVA"},
new Object[] { "1.6 CLASSES & METHODS",
"1.6.1 Constructor",
"1.6.2 Garbage Collection"},
new Object[] {"1.7 INHERITANCE",
"1.7.1 Single Inheritance",
"1.7.2 Multiple Inheritance",
"1.7.3 Multilevel Inheritance",
"1.7.4 Hybrid Inheritance",
new Object[] {"1.8 INTERFACE"},
new Object[] {"1.9 PACKAGES"},
new Object[] {"1.10 EXCEPTION HANDLING",
"1.10.1 try and catch with multiple catch clause,"
"1.10.2 throw and throws",
"1.10.3 finally"},
new Object[] {"1.11 MULTITHREADING",
"1.11.1 States of Thread"},
new Object[] {"1.12 COLLECTIONS"},
new Object[] {"1.13 I/O STREAMS",
"1.13.1 Working with InputStream and OutputStream",
"1.13.2 Working with Reader and Writer"},
new Object[] {"1.14 AWT"},
new Object[] {1.15 APPLET PROGRAMMING",
DefaultMutableTreeNode root = processHierarchy(hierarchy) ;
JTree tree = new JTree(root) ;
content.add(new JScrollPane(tree), BorderLayout.CENTER ;
setSize(275, 300) ;
setVisible(true) ;
}
private DefaultMutableTreeNode processHierarchy (object[] hierarchy) {
DefaultMutableTreeNode node = new
DefaultMutableTreeNode(hierarchy[0]) ;
DefaultMutableTreeNode child;
for(int i=1; i<hierarchy,length; i++) {
object nodeSpecifier = hierarchy[i] ;
if (nodSpecifier instanceofobject[])  // Ie node with children
child = processHierarchy((object[]) nodeSpecifier) ;
else
child = new DefaultMutableTreeNode(nodeSpecifier) ;  // le Leaf
node.add(child) ;
}
return(node) ;
}}
import Javax.swing.*;
import Java.awt.;
public class WindowUtilities {
public static void setNativeLookAndFeel() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) ;
} catch(Exception e) {
System.out.println(" Error setting native LAF : " +e) ;
} }
public static void setJavaLookAndFeel() {
try {
UIManager.setLookAndFeel(UIManager.getCross PlatformLookAndFeelClassName());
} catch(Exception e) {
system.out.println("Error setting Java LAF : "+e) ;
} }
public static void setMotifLookAndFeel() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel") ;
} catch(Exception e) {
System.out.println("Error setting MotifLAF : "+e ) ;
}
  }
public static JFrame openInJFrame(Container content, int Width, int height, String title, Color bgColor) {
JFrame frame = new JFrame(title) ;
frame.setBackground(bgColor) ;
content.setBackground(bgColor);
frame.setSize(width, height);
frame.setContentPane(content) ;
frame.addWindowListener(new ExitListener() ) ;
frame.setVisible(true) ;
return(frame) ;
}
public static JFrame openInJFrame(Container content, int width, int height, String title ;
{
   return (openInJFrame( content, width, height, title, color.white ) ) ;
}
public static JFrame openInJFrame(Container content, int width, int height) {
  return(openInJFrame(content, width, height, content.getClass().getName(), Color.white)) ;
    }
}
import Java.awt.* ;
import Java.awt.event.* ;
public class ExitListner extends WindoAdapter {
public void windowClosing(WindowEvent event) {
System.exit(0) ;
   }
}
The output interface would look like :
Figure here---------


Q. What are digital Signatures ?  Explain.
Ans. Digital signature is an important cryptographic primitives used for uthentication, authoriztionand non-repudiation.  An asymmetric encryption algorithm such as RSA can be used to create and verify digital signature.  The simplest form of the protocol works as follows :
  1. Sender encrypts the document with its private key, thereby singing the document.
  2. Sender sends the signed document to receiver.
  3. Receiver deciphers the document with Sender's public key, thereby verifying the signature.
      The strength of the digital signature lies with the fact that although the public-private key pair for asymmetric encryption is mathematically related, it is computationally in feasible to derive the private key from the corresponding public key.
     A digital signature must meet the following two properties.
  1. It must be unforgettable :  If an entity sings a document M with signature S(M), it is not possible for other entity to produce the same pair <M,S(M)>.
  2. It must be authentic : If someone R receives a digital signature from S, R must be able to verify that the signature is really from S.
      In reality digital signature creation and verification are performed using the combination of hash function  and asymmetric encryption.  To create a digital signature the sender first computers the message authentication code (MAC) or hash of the original message and append the code with the message.  Then hash code is encrypted using asymmetric encryption.  On the reception end the receiver users the  same hash algorithm to compute the hash code of the message decryption the encrypted message using the corresponding public key and compares the hash value.
      If the message is altered, then the finger print of the altered message will not match the fingerprint of the original message.  If the message and its fingerprint are delivered separately, then the recipient can check whether the message has been tampered or not.  Public key cryptography is based on the notion of public key and private key.  Even though everyone knows your public key, they won't compute your private key in your lifetime, no matter how many computing resources they have available.  It may seem difficult to believe that nobody can compute the private key from the public keys, but nobody has ever found an algorithm to do this for the encryption algorithms.  If the keys are sufficiently long brute force would require more computations.  There are two kinds of public\private key pairs : for encryption and for authentication.  If anyone sends you a message that was encrypted with your public encryption key, then you can decrypt it with your private decryption key.  The verification passes only for messages that you signed and it fails if anyone else used his to sign the message.


  1. Java threads and Interrupts in Java programming language
  2. Abstract classes and Generic function in Java
  3. Callback functions in Java Programming language
  4. Constructors in programming language
  5. Static components and constants concept in programming language
  6. Data encapsulation in programming language.
  7. Java threads and Interrupts in Java programming language

53 comments

Excellent post!!! Java is most popular and efficient programming language available in the market today. It helps developers to create stunning desktop/web applications loaded with stunning functionalities.Java Course in Chennai | Best JAVA Training in Chennai|JAVA Training in Chennai

Reply


This technical post helps me to improve my skills set, thanks for this wonder article I expect your upcoming blog, so keep sharing...
Regards,
PHP Training Institute in Chennai|PHP Training in Chennai

Reply

I am following your blog from the beginning, it was so distinct & I had a chance to collect conglomeration of information that helps me a lot to improvise myself. I hope this will help many readers who are in need of this vital piece of information. Thanks for sharing & keep your blog updated.
Regards,
web design training in chennai|web designing course in chennai

Reply

I have read your blog regularly.Your content gives enough clearance about java language.Keep sharing like this.
Regards

Best JAVA Training institute in Chennai
| Java Courses in Chennai

Reply

The strategy you have posted on this technology hepled me to get into the next level and had lot of informations in it.
salesforce training in chennai | salesforce training institute in chennai

Reply

To learn shorter programs when compared to Java then it is the right time to choose python training. There is increasing market demand for professionals who have completed python training.
python training in chennai | python training institutes in chennai

Reply

Web designing is the process that involves collecting ideas and implementing them with the intent of creating the web pages for a website.
Web Designing Course in Chennai | web designing training in chennai

Reply

Really cool post, highly informative and professionally written and I am glad to be a visitor of this perfect blog, thank you for this rare info! , Regards, servicenow training in hyderabad

Reply

Excellent post about Java.After reading your post I had clear about Java.I shared this website that who are in need of this kind of definitions.Keep sharing information like this.
Regards,
Java Training in chennai | Java course in chennai | Best JAVA Training in Chennai

Reply

Java is too helpful to learn Big Data concepts, people who know java they can easily get job in Hadoop field.
Regards,
Big Data Training in Chennai|Big Data Training|Hadoop Training Chennai

Reply

Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
Web designing Course in Chennai | Hadoop Training in Chennai

Reply

I agree with your thoughts!!! As the demand of java programming application keeps on increasing, there is massive demand for java professionals in software development industries. Thus, taking training will assist students to be skilled java developers in leading MNCs.
Regards,
cloud computing training in chennai|cloud computing training|Salesforce Training in Chennai

Reply

A general purpose object oriented language here is massive demand for java professionals in software development industries. Thus, taking training will assist students to be skilled java developers in leading MNCs.
Java Training in chennai | Digital Marketing Training in Chennai | SEO Training in Chennai

Reply

Quite a useful post, I learned some new points here. Thanks admin please keep posting updates regularly to enlighten our knowledge.
Regards,
DOT NET Training in Chennai|DOT NET Course in Chennai|DOT NET Training Institutes in Chennai

Reply

Great information, I like this kind of blog information really very nice and more I can easily new skills are develop after reading that post.
Android Training in Chennai| Selenium Training in Chennai | Software Testing Training in chennai

Reply

wow..!!This post gave me a new idea about level of computer programming.Thanks for sharing this information with me.please share some more codes on the basis of android.
Regards,
JAVA Course in Chennai | JAVA Training in Chennai

Reply

This set of java codes and its information is really very helpful.Actually these java codes are working very well.Thank you for your useful information.
cloud training in Chennai | cloud computing training in chennai

Reply

Excellent post!!Hadoop is especially used for Big Data maintenance. It uses Hadoop distributed file system . Its operating system is in cross platform. Its framework mostly written in java programming language. The other languages which are used by hadoop framework are c, c++ (c with classes) and sometimes in shell scripting.Thank you..!!
Regards,
Hadoop Training in Chennai | Big Data Training in Chennai

Reply

.Net is most preferred programming language among software developers all over the world. It is also considered as most trusted and effective platform to build high performing desktop or enterprise application.
DOTNET Training in Chennai | DOTNET course in Chennai | DOTNET Training Institute in Chennai

Reply

I have read your blog its very attractive and impressive. I like it your blog.


Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai Java Training in Chennai

Java 8 online training Java 8 online training Java Online Training Java Online Training JavaEE Training in Chennai JavaEE Training in Chennai

Reply

Opportunities in PEGA are increasing day by day. This is a future of technology and it has immense scope. Start your career as PEGA developer.
PEGA Training center in Chennai | PEGA Training Chennai | PEGA Training institutes in Chennai

Reply

I have read your blog its very attractive and impressive. I like it your blog.


JavaEE Training in Chennai JavaEE Training in Chennai

Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

Java Online Training Java Online Training Core Java 8 Training in Chennai Java 8 Training in Chennai

Reply

JMS Training Institutes in Chennai JMS Training Institutes in Chennai | JSP Training Institutes in Chennai | Spring Training Institutes in Chennai Spring Training Institutes in ChennaiMicroServices Training Institutes In Chennai Java MicroServices Training Institutes In Chennai
Java EE Training Institutes in Chennai Java EE Training Institutes in Chennai

Reply

Hibernate Training Institutes in ChennaiHibernate Training Institutes in Chennai Hibernate Online Training Hibernate Online Training Hibernate Training in Chennai Hibernate Training in Chennai Java Online Training Java Online Training

Reply

Ethical hacking describes hacking performed by a company or individual to help them to identify potential threats on a computer or network.
Ethical hacking Course in Chennai | Ethical hacking Training in Chennai

Reply

Nice informative content which provided me the required information about the programming language where i have gained lot of knowledge.
PHP training in Chennai | PHP course in Chennai

Reply

Programming testing is the strategy for getting to the item program. The use of writing computer programs is to control the execution of tests. Programming testing field has more occupation open doors in IT sectors.It performs an amazing business.
Thanks,
Software Testing Training in Chennai | Software Testing institutes in Chennai | Software Testing Training institutes

Reply

Excellent content. Thanks for sharing content which is very useful that provided me the required information.
Cloud Computing Training in Chennai | Cloud Computing Courses in Chennai

Reply

Very interesting content which helps me to get the in depth knowledge about the technology. To know more details about the course visit this website.
Digital marketing course in Chennai | Digital marketing training in Chennai

Reply

I have been reading out a lot of your articles.
I will certainly bookmark your Blog.
Free Devops Training
Hybris Training
Emc San Training

Reply

Hi, you have given really informative post. Thanks for sharing this post to our vision. Learn Hadoop Online Training will helps you to reach your goal.Selenium Online Training

Reply

Nice post. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it. Web Designing Training Institute in Chennai | Web Designing Training Institute in Velachery.

Reply

The best thing is that your blog really informative thanks for your great information! Keep sharing.
cloud erp in chennai

Reply

thank you for such a great article with us. hope it will be much useful for us. please keep on updating..
Web designing course in chennai

Reply

Thank you sharing the excellent post . you helped me to gain more information on the latest technique
JAVA Training in Chennai | JAVA Training

Reply

I appreciate you and I would like to read your next post.
Thanks for sharing this useful information.
SEO jobs in Hyderabad

Reply

Thanks for taking time to share this post.It is really useful.Continue sharing more like this.
Regards,
Java Training in Chennai

Reply

informative blog thanks for providing such a great information.
SEO jobs in Hyderabad

Reply

The strategy you have posted on this technology helped me to get into the next level in selenium and had got confident that i can gain selenium Jobs in hyderabad.

Reply

Recently I read your blog very informative and helpful thanks for the share.
Cloud Computing training institute in Gurgaon | ethical hacking training in Gurgaon

Reply

Excellent Blog very imperative good content, this article is useful to beginners and real time Employees. DevOps Online Training

Reply

I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly
CCNA jobs in Hyderabad .

Reply

really cool post, highly informative and professionally written and I am glad to be a visitor of this perfect blog, thank you for this rare info! , Regards,
servicenow training in hyderabad
devops training in hyderabad

Reply


Thanks a lot! You made a new blog entry to answer my question; I really appreciate your time and effort.
java training in chennai |
java training institute in chennai

Reply

Post a Comment

www.CodeNirvana.in

www.posthatke.com. Powered by Blogger.

Google+ Followers

Copyright © www.posthatke.com | Blogger Templates | Designed By posthatke.com