The document provides instructions to examiners for evaluating answers to an Advanced Java Programming exam. It notes that examiners should assess understanding rather than just checking for exact word-for-word matches. It also indicates that figures, programming concepts, and numerical problems should be evaluated based on equivalent solutions rather than requiring an exact match. The document provides examples of questions that may be asked on the exam related to Java controls, JDBC drivers, TCP vs UDP, and InetAddress factory methods.
CIS 407 STUDY Inspiring Innovation--cis407study.comKeatonJennings91
This document contains information about various CIS 407 exams, labs, assignments, and case studies for an online course. It includes sample exam questions, lab exercise instructions, assignment descriptions, and a case study on creating bar charts in Java. The assignments involve building an interactive Java application for an insurance agent to generate quotes. Students are tasked with implementing classes, calculating premiums, getting user input, and modifying the application to use different input/output methods.
This document provides guidelines for conducting practical exercises for an Advanced Database Management Systems course. It includes 11 exercises covering concepts like SQL statements, functions, normalization, joins, views, and PL/SQL programming. Students are expected to complete the exercises over 12 sessions in 7 days under faculty guidance. Exercises are assessed and students must score a minimum of 40% combined on guided and unguided assessments to pass. The document outlines software and hardware requirements and provides instructions for completing the exercises and documenting the work.
The document discusses JDBC and provides information on its objectives, architecture, drivers, API, and how to create JDBC applications. The key points covered are that JDBC has two layers - the application layer and driver layer; there are four types of JDBC drivers; and the main steps to create a JDBC application are to load a driver, connect to a database, create and execute statements, and handle exceptions.
The document discusses various topics in JDBC including prepared statements, transactions, batch updates, stored procedures, and metadata. Prepared statements allow passing parameters to SQL statements and improve performance. Transactions commit or rollback multiple statements as a single unit. Batch updates execute a group of statements together more efficiently. Stored procedures are called using CallableStatement and parameters can be IN, OUT, or INOUT. Database metadata describes database structure and result set metadata describes result columns.
The document provides an overview of key concepts in using the PreparedStatement object in JDBC, including querying and modifying data, methods, retrieving and inserting rows, updating and deleting rows, managing transactions, batch updates, stored procedures, and metadata. Specifically, it discusses how to create PreparedStatements, set parameters, execute queries and updates, manage transactions, perform batch operations, call stored procedures, and retrieve metadata about the database and result sets.
This document provides a lab manual for the fourth semester computer science engineering course on Object Oriented Technology. It includes the syllabus, rationale for object oriented programming, hardware and software requirements, a list of practical experiments to be conducted, and sample code for some of the experiments. The experiments cover topics like function overloading, inheritance, polymorphism, constructors, destructors, copy constructors, friend functions, and use of local, static and global objects. Each experiment is followed by sample output and questions related to the concepts covered in the program. The document aims to provide guidance to students on the practical implementation of object oriented programming concepts using C++.
Analysis of 3-D Model in ANSYS 9.0 by Java Program and Macros Using Interlink...IDES Editor
ANSYS, one of the CAE software is widely used to
perform various types of analysis under various loading
condition. But the major drawback of the software is that it
does not provide ‘undo’ option because of which it becomes
quite hectic to edit the entered parameter in the same iteration.
Also slight change in dimension or in boundary condition,
force user to perform the same steps of analysis once again.
Macro files are used to store ANSYS Parametric Design
Language (APDL). So the objective of the present paper is to
edit macro file as per the desired conditions which will reflect
in ANSYS Parametric Design Language (APDL) program in
ANSYS software. The main aim in this research work is to
interlink macro file and computer program which will helpful
to edit macro file conversely the updation will be seen in
ANSYS model automatically. For detailed, CFD analysis of
2-D duct for laminar flow is considered. For different
dimensions of 2-D duct, the model is tested and the loading
condition is changed through a Java program. This work will
be very useful to perform analysis for the beginner level user.
Also the time required modifying the model and to perform
its analysis is reduced promisingly in the area of CAE
technology.
CIS 407 STUDY Inspiring Innovation--cis407study.comKeatonJennings91
This document contains information about various CIS 407 exams, labs, assignments, and case studies for an online course. It includes sample exam questions, lab exercise instructions, assignment descriptions, and a case study on creating bar charts in Java. The assignments involve building an interactive Java application for an insurance agent to generate quotes. Students are tasked with implementing classes, calculating premiums, getting user input, and modifying the application to use different input/output methods.
This document provides guidelines for conducting practical exercises for an Advanced Database Management Systems course. It includes 11 exercises covering concepts like SQL statements, functions, normalization, joins, views, and PL/SQL programming. Students are expected to complete the exercises over 12 sessions in 7 days under faculty guidance. Exercises are assessed and students must score a minimum of 40% combined on guided and unguided assessments to pass. The document outlines software and hardware requirements and provides instructions for completing the exercises and documenting the work.
The document discusses JDBC and provides information on its objectives, architecture, drivers, API, and how to create JDBC applications. The key points covered are that JDBC has two layers - the application layer and driver layer; there are four types of JDBC drivers; and the main steps to create a JDBC application are to load a driver, connect to a database, create and execute statements, and handle exceptions.
The document discusses various topics in JDBC including prepared statements, transactions, batch updates, stored procedures, and metadata. Prepared statements allow passing parameters to SQL statements and improve performance. Transactions commit or rollback multiple statements as a single unit. Batch updates execute a group of statements together more efficiently. Stored procedures are called using CallableStatement and parameters can be IN, OUT, or INOUT. Database metadata describes database structure and result set metadata describes result columns.
The document provides an overview of key concepts in using the PreparedStatement object in JDBC, including querying and modifying data, methods, retrieving and inserting rows, updating and deleting rows, managing transactions, batch updates, stored procedures, and metadata. Specifically, it discusses how to create PreparedStatements, set parameters, execute queries and updates, manage transactions, perform batch operations, call stored procedures, and retrieve metadata about the database and result sets.
This document provides a lab manual for the fourth semester computer science engineering course on Object Oriented Technology. It includes the syllabus, rationale for object oriented programming, hardware and software requirements, a list of practical experiments to be conducted, and sample code for some of the experiments. The experiments cover topics like function overloading, inheritance, polymorphism, constructors, destructors, copy constructors, friend functions, and use of local, static and global objects. Each experiment is followed by sample output and questions related to the concepts covered in the program. The document aims to provide guidance to students on the practical implementation of object oriented programming concepts using C++.
Analysis of 3-D Model in ANSYS 9.0 by Java Program and Macros Using Interlink...IDES Editor
ANSYS, one of the CAE software is widely used to
perform various types of analysis under various loading
condition. But the major drawback of the software is that it
does not provide ‘undo’ option because of which it becomes
quite hectic to edit the entered parameter in the same iteration.
Also slight change in dimension or in boundary condition,
force user to perform the same steps of analysis once again.
Macro files are used to store ANSYS Parametric Design
Language (APDL). So the objective of the present paper is to
edit macro file as per the desired conditions which will reflect
in ANSYS Parametric Design Language (APDL) program in
ANSYS software. The main aim in this research work is to
interlink macro file and computer program which will helpful
to edit macro file conversely the updation will be seen in
ANSYS model automatically. For detailed, CFD analysis of
2-D duct for laminar flow is considered. For different
dimensions of 2-D duct, the model is tested and the loading
condition is changed through a Java program. This work will
be very useful to perform analysis for the beginner level user.
Also the time required modifying the model and to perform
its analysis is reduced promisingly in the area of CAE
technology.
The document discusses various components of a Struts application including:
1. The struts-config.xml file which specifies the flow control and mappings between view components and controllers.
2. Form beans (ActionForms) which are JavaBeans that hold view data temporarily and extend ActionForm.
3. Action classes which extend Action and handle requests by capturing input, invoking business logic, and returning view mappings.
4. The ActionServlet which acts as the front controller, handling requests and dispatching them to subcontrollers (Action classes) based on configuration.
5. JSPs which are used to generate the input and response pages, using Struts tag libraries.
The document
This document appears to be an assignment submission for a post graduate diploma in information technology. It contains 10 questions related to Java programming and the answers/code snippets provided for each question. The questions cover topics like simple interest calculation, sum of digits, Fibonacci series, converting decimal to Roman numerals, prime numbers, nested for loops to print patterns, recursive factorial, defining custom exceptions and creating a simple welcome applet.
This document discusses Hibernate and Java persistence. It begins by explaining that Hibernate is an open source Java application framework used to implement object/relational mapping (ORM). It allows Java applications to communicate with relational databases using Hibernate's API instead of directly using JDBC. The document then discusses the traditional and ORM approaches to Java persistence and how Hibernate implements the ORM approach using mapping files, configuration files, and its engine to generate SQL statements. It also covers persistent classes, Hibernate's architecture, and how CRUD operations are performed using Hibernate.
The document discusses various advanced features of JDBC including using prepared statements, managing transactions, performing batch updates, and calling stored procedures. Prepared statements improve performance by compiling SQL statements only once. Transactions allow grouping statements to execute atomically through commit and rollback. Batch updates reduce network calls by executing multiple statements as a single unit. Stored procedures are called using a CallableStatement object which can accept input parameters and return output parameters.
The document provides information on working with joins, the JDBC API, and isolation levels in Java database applications. It discusses different types of joins like inner joins, cross joins, and outer joins. It describes the key interfaces in the JDBC API like Statement, PreparedStatement, ResultSet, Connection, and DatabaseMetaData. It also covers isolation levels and how they prevent issues with concurrently running transactions accessing a database.
The document discusses accessing and manipulating data in ADO.NET. It covers pre-assessment questions about ADO.NET concepts like data providers and data binding. It then discusses implementing simple and complex data binding to controls. Finally, it discusses filtering and sorting data using parameterized queries, the Select method on datasets, and DataView objects.
Database access and JDBC
Topics:
- Introduction to JDBC
- Accessing a database: practical steps
- Prepared statements
- Design patterns (DAO)
- Connection pooling
Teaching material for the course of "Tecniche di Programmazione" at Politecnico di Torino in year 2013/2014. More information: http://bit.ly/tecn-progr
This document provides instructions for controlling the MicroManager microscopy software via MATLAB to enable real-time cell image processing capabilities. It outlines how to import MicroManager classes into MATLAB, set up the environment, and provides an example workflow of how the existing ACTIVE image analysis software could be modified to allow real-time processing and control of the microscope during live cell imaging. Key areas that could be automated based on analysis results are also discussed.
This document introduces programming and the basics of computer architecture. It discusses what programming is, the anatomy of a computer including central processing units and memory, machine code, and high-level languages. It also covers Java as a programming language, becoming familiar with development environments, and writing a simple "Hello World" program in Java to demonstrate compiling and running a program. Errors like syntax errors and logic errors are introduced.
This document presents a multi-level methodology for developing UML sequence diagrams (SQDs) in a systematic way. The methodology has three levels - the object framework level, responsibility assignment level, and visual pattern level. Each level breaks the SQD development process into discrete stages and provides guidelines to help avoid common errors. The goal is to serve as an easy-to-use reference for novice SQD modelers to develop correct and consistent SQDs.
The document discusses application packages and classes in PeopleSoft. It defines what an application package and class are, and explains how to create them using Application Designer. It also covers object-oriented concepts like classes, objects, encapsulation, inheritance, polymorphism. Additionally, it discusses class structure, importing packages and classes, access controls, defining methods, abstract methods, interfaces, constructors, get/set methods, and exception handling.
Finding latent code errors via machine learning over program ...butest
The document proposes a technique that uses machine learning to identify program properties from dynamic analysis that are likely to indicate errors. It trains models on properties from erroneous and fixed programs, and applies the models to rank properties of new code based on their likelihood of revealing errors. An implementation demonstrates it can increase the concentration of useful error-indicating properties in its output by factors of 50x for C programs and 4.8x for Java programs.
Dịch vụ : Thiết kế website (http://www.web360.com.vn/) - Dịch vụ thiết kế web khách sạn (http://web360.com.vn/Thiet-ke-Web-khach-san.html)
Web360 công ty thiết kế web với nhiều năm kinh nghiệm , chúng tôi cung cấp các giải pháp dành cho những khách hàng có nhu cầu xây dựng website để đẩy mạnh công việc kinh doanh, mở rộng các kênh bán hàng, tăng cường khả năng giao tiếp với khách hàng hoặc muốn khẳng định đẳng cấp hoặc thương hiệu của công ty.
Thiết kế web giá rẻ nhất đà nẵng(http://web360.com.vn/Thiet-ke-web-gia-re-da-nang.html)
DỊCH VỤ THIẾT KẾ WEB CHUYÊN NGHIỆP CỦA CHÚNG TÔI NHƯ SAU :
1. Giao diện website được thiết kế đẹp mắt, chuyên nghiệp.
2. Website được nghiên cứu kỹ các đối tượng khách hàng, phân tích nhu cầu, thói quen và hành vi của họ khi duyệt web để xây dựng các chức năng và nội dung phù hợp nhằm biến họ trở thành khách hàng thực sự của bạn.
3. Nghiên cứu rất kỹ các đối thủ cạnh tranh của bạn trên mạngi internet và sẽ tư vấn cho bạn cách để bạn vượt qua họ.
4. Các chuyên gia của chúng tôi cũng sẽ tư vấn cho bạn cách viết nội dung và sử dụng những từ khóa có giá trị nhằm thu hút và giữ chân khách hàng, đồng thời tạo thiện cảm cho các công cụ tìm kiếm.
5. Tối ưu hóa công cụ tìm kiếm chuẩn SEO google
Liên hệ với chúng tôi để được tư vấn thiết kế web tại Đà Nẵng tận tình nhất !
Thiet ke web da nang - Cong ty thiet ke web tai da nang (http://web360.com.vn/Thiet-ke-web-Da-Nang.html)
Liên hệ : 090.52.52.360 - 0905.595.360(Mr Hoàng)
Email : info@web360.com.vn (info@web360.com.vn)
Website : www.web360.com.vn (http://web360.com.vn/)
Địa chỉ : 44 Ngô Chi Lan - Q.Hải Châu - TP.Đà Nẵng
Chúng tôi luôn nỗ lực đem lại cho khách hàng những sản phẩm và dịch vụ tốt nhất !
dịch vụ,thiết kế,thiết kế web,chuyên nghiệp,dịch vụ thiết kế,dịch vụ thiết kế web đà nẵng
Class clusters group a number of private subclasses under a public abstract superclass. This simplifies the publicly visible architecture without reducing functionality. For example, instead of distinct classes for different number types, there could be a single Number superclass with private subclasses for specific types. This keeps the interface simple while allowing different internal representations.
The Object oriented system developed by Dr Pradhan P L which will be helpful to GATE-UPSC-NET Exam for B Tech, M Tech CSE ,IT, BCA, MCA & MSc ( Computer Sc & IT )
OOS MCQ 2018 Developed by Dr PL Pradhan, IT Dept, TGPCET, NAGPUR, INDIA
Subject Teacher of OOM as per RTM Nagpur university
The WEKA software provides a collection of machine learning algorithms for data mining tasks. It contains tools for classification, clustering, regression, filtering, and feature selection. The software is open source and written in Java, providing a uniform interface to standard machine learning techniques. It aims to apply machine learning methods to practical problems and make these techniques more accessible and usable.
Here are the steps to create the UI for the banking portal application using Spring MVC:
1. Create a Spring MVC project in your IDE.
2. Create a Controller class called HomeController and annotate it with @Controller. Map it to the home page URL using @RequestMapping.
3. Create another Controller class called LoginController and annotate it with @Controller. Map it to the login page URL.
4. Create a JSP page called home.jsp to display the home page content.
5. Create another JSP page called login.jsp to display the login form.
6. Configure the view resolvers in the Spring configuration file to resolve JSP views.
7
This document summarizes methods of dynamic binary analysis and the Valgrind tool. It discusses how dynamic binary analysis tools like Valgrind use techniques like dynamic binary instrumentation and shadow memory to detect errors in programs as they execute. Valgrind's Memcheck tool tracks definedness of values at the bit level to detect errors like bad memory accesses and uses of uninitialized data with low false positive rates. The document also explains Valgrind's use of disassembly and re-synthesis to translate machine code to an intermediate representation for instrumentation.
1. The document discusses object-oriented programming concepts like abstraction, encapsulation, inheritance, polymorphism, and dynamic binding.
2. It then provides details on the history and features of Java, including how Java code is compiled and run on the Java Virtual Machine.
3. Core object-oriented features of Java like classes, objects, constructors, and method overloading are explained.
The document provides instructions for examiners evaluating answers to questions on a technical education exam. It states that examiners should focus on assessing the understanding level of candidates rather than comparing answers word-for-word to the model answers. It also notes several ways examiners can give partial credit, such as for diagrams where the principles are shown even if not identical, or for numerical problems where the approach is valid even if values differ slightly. The instructions aim to guide examiners to evaluate based on the concepts and reasoning demonstrated rather than superficial similarities or differences to the model answers.
The document outlines the program structure for the second year of engineering at the University of Mumbai for semesters 3 and 4. It includes details of the courses, teaching scheme, examination scheme, labs, and syllabus. Some of the key courses include Data Structures, Database Management Systems, Principles of Communication, and Paradigms and Computer Programming Fundamentals. The syllabus covers topics like Java fundamentals, OOP concepts, inheritance, packages, interfaces, exception handling, multithreading, I/O streams, and GUI programming using AWT and Swing. Students will complete labs related to the coursework and a mini project to develop a front-end or backend application using Java.
This document outlines lab work assignments for an object-oriented programming course. The assignments include:
1) Creating a class to register student details and prevent duplicate entries.
2) Creating a banking account class to perform deposit, withdrawal, and statement printing transactions.
3) Creating a mobile phone class to store phone details and allow user login/selection of products to calculate total cost.
The document discusses various components of a Struts application including:
1. The struts-config.xml file which specifies the flow control and mappings between view components and controllers.
2. Form beans (ActionForms) which are JavaBeans that hold view data temporarily and extend ActionForm.
3. Action classes which extend Action and handle requests by capturing input, invoking business logic, and returning view mappings.
4. The ActionServlet which acts as the front controller, handling requests and dispatching them to subcontrollers (Action classes) based on configuration.
5. JSPs which are used to generate the input and response pages, using Struts tag libraries.
The document
This document appears to be an assignment submission for a post graduate diploma in information technology. It contains 10 questions related to Java programming and the answers/code snippets provided for each question. The questions cover topics like simple interest calculation, sum of digits, Fibonacci series, converting decimal to Roman numerals, prime numbers, nested for loops to print patterns, recursive factorial, defining custom exceptions and creating a simple welcome applet.
This document discusses Hibernate and Java persistence. It begins by explaining that Hibernate is an open source Java application framework used to implement object/relational mapping (ORM). It allows Java applications to communicate with relational databases using Hibernate's API instead of directly using JDBC. The document then discusses the traditional and ORM approaches to Java persistence and how Hibernate implements the ORM approach using mapping files, configuration files, and its engine to generate SQL statements. It also covers persistent classes, Hibernate's architecture, and how CRUD operations are performed using Hibernate.
The document discusses various advanced features of JDBC including using prepared statements, managing transactions, performing batch updates, and calling stored procedures. Prepared statements improve performance by compiling SQL statements only once. Transactions allow grouping statements to execute atomically through commit and rollback. Batch updates reduce network calls by executing multiple statements as a single unit. Stored procedures are called using a CallableStatement object which can accept input parameters and return output parameters.
The document provides information on working with joins, the JDBC API, and isolation levels in Java database applications. It discusses different types of joins like inner joins, cross joins, and outer joins. It describes the key interfaces in the JDBC API like Statement, PreparedStatement, ResultSet, Connection, and DatabaseMetaData. It also covers isolation levels and how they prevent issues with concurrently running transactions accessing a database.
The document discusses accessing and manipulating data in ADO.NET. It covers pre-assessment questions about ADO.NET concepts like data providers and data binding. It then discusses implementing simple and complex data binding to controls. Finally, it discusses filtering and sorting data using parameterized queries, the Select method on datasets, and DataView objects.
Database access and JDBC
Topics:
- Introduction to JDBC
- Accessing a database: practical steps
- Prepared statements
- Design patterns (DAO)
- Connection pooling
Teaching material for the course of "Tecniche di Programmazione" at Politecnico di Torino in year 2013/2014. More information: http://bit.ly/tecn-progr
This document provides instructions for controlling the MicroManager microscopy software via MATLAB to enable real-time cell image processing capabilities. It outlines how to import MicroManager classes into MATLAB, set up the environment, and provides an example workflow of how the existing ACTIVE image analysis software could be modified to allow real-time processing and control of the microscope during live cell imaging. Key areas that could be automated based on analysis results are also discussed.
This document introduces programming and the basics of computer architecture. It discusses what programming is, the anatomy of a computer including central processing units and memory, machine code, and high-level languages. It also covers Java as a programming language, becoming familiar with development environments, and writing a simple "Hello World" program in Java to demonstrate compiling and running a program. Errors like syntax errors and logic errors are introduced.
This document presents a multi-level methodology for developing UML sequence diagrams (SQDs) in a systematic way. The methodology has three levels - the object framework level, responsibility assignment level, and visual pattern level. Each level breaks the SQD development process into discrete stages and provides guidelines to help avoid common errors. The goal is to serve as an easy-to-use reference for novice SQD modelers to develop correct and consistent SQDs.
The document discusses application packages and classes in PeopleSoft. It defines what an application package and class are, and explains how to create them using Application Designer. It also covers object-oriented concepts like classes, objects, encapsulation, inheritance, polymorphism. Additionally, it discusses class structure, importing packages and classes, access controls, defining methods, abstract methods, interfaces, constructors, get/set methods, and exception handling.
Finding latent code errors via machine learning over program ...butest
The document proposes a technique that uses machine learning to identify program properties from dynamic analysis that are likely to indicate errors. It trains models on properties from erroneous and fixed programs, and applies the models to rank properties of new code based on their likelihood of revealing errors. An implementation demonstrates it can increase the concentration of useful error-indicating properties in its output by factors of 50x for C programs and 4.8x for Java programs.
Dịch vụ : Thiết kế website (http://www.web360.com.vn/) - Dịch vụ thiết kế web khách sạn (http://web360.com.vn/Thiet-ke-Web-khach-san.html)
Web360 công ty thiết kế web với nhiều năm kinh nghiệm , chúng tôi cung cấp các giải pháp dành cho những khách hàng có nhu cầu xây dựng website để đẩy mạnh công việc kinh doanh, mở rộng các kênh bán hàng, tăng cường khả năng giao tiếp với khách hàng hoặc muốn khẳng định đẳng cấp hoặc thương hiệu của công ty.
Thiết kế web giá rẻ nhất đà nẵng(http://web360.com.vn/Thiet-ke-web-gia-re-da-nang.html)
DỊCH VỤ THIẾT KẾ WEB CHUYÊN NGHIỆP CỦA CHÚNG TÔI NHƯ SAU :
1. Giao diện website được thiết kế đẹp mắt, chuyên nghiệp.
2. Website được nghiên cứu kỹ các đối tượng khách hàng, phân tích nhu cầu, thói quen và hành vi của họ khi duyệt web để xây dựng các chức năng và nội dung phù hợp nhằm biến họ trở thành khách hàng thực sự của bạn.
3. Nghiên cứu rất kỹ các đối thủ cạnh tranh của bạn trên mạngi internet và sẽ tư vấn cho bạn cách để bạn vượt qua họ.
4. Các chuyên gia của chúng tôi cũng sẽ tư vấn cho bạn cách viết nội dung và sử dụng những từ khóa có giá trị nhằm thu hút và giữ chân khách hàng, đồng thời tạo thiện cảm cho các công cụ tìm kiếm.
5. Tối ưu hóa công cụ tìm kiếm chuẩn SEO google
Liên hệ với chúng tôi để được tư vấn thiết kế web tại Đà Nẵng tận tình nhất !
Thiet ke web da nang - Cong ty thiet ke web tai da nang (http://web360.com.vn/Thiet-ke-web-Da-Nang.html)
Liên hệ : 090.52.52.360 - 0905.595.360(Mr Hoàng)
Email : info@web360.com.vn (info@web360.com.vn)
Website : www.web360.com.vn (http://web360.com.vn/)
Địa chỉ : 44 Ngô Chi Lan - Q.Hải Châu - TP.Đà Nẵng
Chúng tôi luôn nỗ lực đem lại cho khách hàng những sản phẩm và dịch vụ tốt nhất !
dịch vụ,thiết kế,thiết kế web,chuyên nghiệp,dịch vụ thiết kế,dịch vụ thiết kế web đà nẵng
Class clusters group a number of private subclasses under a public abstract superclass. This simplifies the publicly visible architecture without reducing functionality. For example, instead of distinct classes for different number types, there could be a single Number superclass with private subclasses for specific types. This keeps the interface simple while allowing different internal representations.
The Object oriented system developed by Dr Pradhan P L which will be helpful to GATE-UPSC-NET Exam for B Tech, M Tech CSE ,IT, BCA, MCA & MSc ( Computer Sc & IT )
OOS MCQ 2018 Developed by Dr PL Pradhan, IT Dept, TGPCET, NAGPUR, INDIA
Subject Teacher of OOM as per RTM Nagpur university
The WEKA software provides a collection of machine learning algorithms for data mining tasks. It contains tools for classification, clustering, regression, filtering, and feature selection. The software is open source and written in Java, providing a uniform interface to standard machine learning techniques. It aims to apply machine learning methods to practical problems and make these techniques more accessible and usable.
Here are the steps to create the UI for the banking portal application using Spring MVC:
1. Create a Spring MVC project in your IDE.
2. Create a Controller class called HomeController and annotate it with @Controller. Map it to the home page URL using @RequestMapping.
3. Create another Controller class called LoginController and annotate it with @Controller. Map it to the login page URL.
4. Create a JSP page called home.jsp to display the home page content.
5. Create another JSP page called login.jsp to display the login form.
6. Configure the view resolvers in the Spring configuration file to resolve JSP views.
7
This document summarizes methods of dynamic binary analysis and the Valgrind tool. It discusses how dynamic binary analysis tools like Valgrind use techniques like dynamic binary instrumentation and shadow memory to detect errors in programs as they execute. Valgrind's Memcheck tool tracks definedness of values at the bit level to detect errors like bad memory accesses and uses of uninitialized data with low false positive rates. The document also explains Valgrind's use of disassembly and re-synthesis to translate machine code to an intermediate representation for instrumentation.
1. The document discusses object-oriented programming concepts like abstraction, encapsulation, inheritance, polymorphism, and dynamic binding.
2. It then provides details on the history and features of Java, including how Java code is compiled and run on the Java Virtual Machine.
3. Core object-oriented features of Java like classes, objects, constructors, and method overloading are explained.
The document provides instructions for examiners evaluating answers to questions on a technical education exam. It states that examiners should focus on assessing the understanding level of candidates rather than comparing answers word-for-word to the model answers. It also notes several ways examiners can give partial credit, such as for diagrams where the principles are shown even if not identical, or for numerical problems where the approach is valid even if values differ slightly. The instructions aim to guide examiners to evaluate based on the concepts and reasoning demonstrated rather than superficial similarities or differences to the model answers.
The document outlines the program structure for the second year of engineering at the University of Mumbai for semesters 3 and 4. It includes details of the courses, teaching scheme, examination scheme, labs, and syllabus. Some of the key courses include Data Structures, Database Management Systems, Principles of Communication, and Paradigms and Computer Programming Fundamentals. The syllabus covers topics like Java fundamentals, OOP concepts, inheritance, packages, interfaces, exception handling, multithreading, I/O streams, and GUI programming using AWT and Swing. Students will complete labs related to the coursework and a mini project to develop a front-end or backend application using Java.
This document outlines lab work assignments for an object-oriented programming course. The assignments include:
1) Creating a class to register student details and prevent duplicate entries.
2) Creating a banking account class to perform deposit, withdrawal, and statement printing transactions.
3) Creating a mobile phone class to store phone details and allow user login/selection of products to calculate total cost.
The document appears to be a laboratory manual for a Java programming lab course. It includes:
1) An outline of the course syllabus, marks scheme, and lab plan covering topics like classes and objects, inheritance, exceptions, files and more across 10 lab turns.
2) Objectives of the lab to develop understanding of Java concepts like OOPs, packages, strings, files and concurrency.
3) Examples of basic Java programs to print text, calculate area, check prime numbers and generate a number ladder.
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxketurahhazelhurst
CASE STUDY
Internet/Excel Exercises, page 434, text
Record your findings in a Word document and submit it online
IBM has substantial operations in many countries, including the United States, Canada, and Germany. Go to finance.yahoo.com/q?s=ibm.
1. Click on Historical Prices. (Or apply this exercise to a different MNC.) Set the date range so that you can obtain quarterly values of the U.S. stock index for the last 20 quarters. Insert the quarterly data on a spreadsheet. Compute the percentage change in IBM’s stock price for each quarter. Next go to finance.yahoo.com/stock-center/ and click (under U.S.) on S&P Composite 1500 Index, which represents the U.S. stock market index, so that you can derive the quarterly percentage change in the U.S. stock index over the last 20 quarters. Then run a regression analysis with IBM’s quarterly return (percentage change in stock price) as the dependent variable and the quarterly percentage change in the U.S. stock market’s value as the independent variable. (Appendix C explains how Excel can be used to run regression analysis.) The slope coefficient serves as an estimate of the sensitivity of IBM’s value to the U.S. market returns. Also, check the fit of the relationship based on the R-squared statistic.
2. Go to finance.yahoo.com/stock-center/ and click (under “Europe”) on DAX, which represents the German stock market index. Repeat the process described in exercise 1 so that you can assess IBM’s sensitivity to the German stock market. Compare the slope coefficient between the two analyses. Is IBM’s value more sensitive to the U.S. market or the German market? Does the U.S. market or the German market explain a higher proportion of the variation in IBM’s returns (check the R-squared statistic)? Offer an explanation of your results.
Lab 5 Database Security
Use the script from week 1 for the week 5 lab.
1. Create four new users
a. The first user will have full rights to the database
b. The second user grant access to the Client’s table and allow them the rights to INSERT data into the clients table
c. The third user grant rights to create user logins and reset passwords
d. The fourth user grant column rights to the Course_Activity table allow access to the Course Code and Grade column. Allow user to UPDATE a maximum of 5 times per hour.
2. Login with each user to demonstrate the rights you have given them
a. User 1 login and create a VIEW for user 2 that just displays the Client table
b. User 2 login and add 3 more clients to the Clients table
c. User 3 login create two new users
d. User 4 login and UPDATE two new entries for Course Code and Grade Column for Client 1 and 2
e. For each user run the Show Privileges command to show correct rights and permissions have been applied
3. Show Log Files: For each user show log files (since we do not have MySQL Enterprise we cannot use the Audit function but as a substitute we can use the built-in log file function)
4. Create a Stored Procedure with User ...
Unit Testing Frameworks: A comparative studyIRJET Journal
This document provides a comparative study of various unit testing frameworks for different programming languages like C++, Java, and Python. It discusses the key features and differences between frameworks like Google Test and Google Mock, CppUnit, CppUTest for C++; JUnit and JMock, TestNG for Java; and Pytest and unittest for Python. The document finds that Google Test is more feature-rich for C++ compared to other frameworks. For Java, JUnit is considered best. And many Python projects are migrating from unittest to Pytest due to advantages like easier syntax and fixture reuse. The document concludes that choosing the right framework depends on the programming language and project requirements.
Inheritance is a key concept in object-oriented programming that allows a derived class to inherit attributes and behaviors (data members and member functions) from a base class. This allows code reuse and makes it easier to create and add new reusable components. A derived class inherits attributes and behaviors of the base class and can add its own attributes and behaviors. Inheritance provides code sharing, extension of existing classes, and polymorphism.
PRG 420 Week 3 Individual Assignment Netbeans Project (annual compensation with commission)/build.xml
Builds, tests, and runs the project PRG420V10_Week3.
PRG 420 Week 3 Individual Assignment Netbeans Project (annual compensation with commission)/build/classes/.netbeans_automatic_build
PRG 420 Week 3 Individual Assignment Netbeans Project (annual compensation with commission)/build/classes/DriverCalculator.classpublicsynchronizedclass DriverCalculator {
public void DriverCalculator();
publicstatic void main(String[]);
}
PRG 420 Week 3 Individual Assignment Netbeans Project (annual compensation with commission)/build/classes/SalesPerson.classpublicsynchronizedclass SalesPerson {
double fixedSalary;
double annualSales;
double commission;
double target;
public void SalesPerson(double);
public double getTotalAnnualCompensation();
}
PRG 420 Week 3 Individual Assignment Netbeans Project (annual compensation with commission)/manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
PRG 420 Week 3 Individual Assignment Netbeans Project (annual compensation with commission)/nbproject/build-impl.xml
Must set src.dir
Must set test.src.dir
Must set build.dir
Must set dist.dir
Must set build.classes.dir
Must set dist.javadoc.dir
Must set build.test.classes.dir
Must set build.test.results.dir
Must set build.classes.excludes
Must set dist.jar
.
The document summarizes 5 design patterns: Singleton, Strategy, Decorator, Facade, and Bulk State Transition. It provides code examples and explanations of how each pattern is implemented in Apex to solve common problems like repeated object instantiation, selecting algorithms at runtime, adding temporary fields, simplifying complex classes, and performing bulk actions. The document was presented by Ankit Rustagi and covers implementing these patterns in Apex along with handling governor limits. Contact information is provided at the end for any additional questions.
The document provides instructions to examiners for evaluating answers to examination questions. It states that examiners should assess understanding level rather than checking for word-to-word matches. Language errors like spelling mistakes should not be given more importance except for subjects related to language. While assessing figures, examiners may give credit for principal components. For numerical problems, credit may be given in a step-wise manner. In some cases, examiners can use their judgment to give credit for relevant answers based on a candidate's understanding. For programming questions, credit may be given to equivalent programs based on similar concepts.
This document outlines the syllabus breakdown for Class XII Informatics Practices subject for the 2012-2013 academic year. It includes:
1) The units of study, topics covered in each unit, and time period and marks allotted for theory and practical components. The four units are Networking and Open Standards, Programming, Relational Database Management System, and IT Applications.
2) A month-by-month schedule of topics to be covered in the theory component, including the number of periods and tentative working days for each topic.
3) An outline of the evaluation process and requirements for the practical examination, including problems/queries to practice, a practical record file, a group project, and a
1) The document provides instructions to examiners for evaluating answers to exam questions for a Database Management System subject. It includes guidelines on assessing understanding rather than exact word-for-word matches, and allowing for variation in figures while still giving partial credit.
2) The document then lists several exam questions and provides sample answers and marking schemes for awarding points. The questions cover topics like disadvantages of file processing systems, data abstraction, normalization, SQL commands, functions, and cursors.
3) Sample answers are provided for questions on set operators, string functions, and exception handling in SQL with examples. Guidelines state examiners should award partial marks for explanations and examples in answers.
The document contains a sample exam for the Microsoft 70-499 certification with 15 multiple choice questions and answers. The exam covers topics like Visual Studio Team Foundation Server, Microsoft Test Manager, unit testing, and Scrum methodologies.
.NET is designed to solve problems that have plagued programmers in the past like incompatibilities between programming languages and technologies. It provides a common language runtime and type system that allows different languages to work together. The .NET Framework handles many common programming tasks like serialization automatically through metadata and provides a large class library for common functions.
The document discusses UI testing techniques for handling complex user interfaces at scale. It provides an overview of different types of tests like unit tests, integration tests, and end-to-end tests. Unit tests allow testing small pieces of functionality in isolation while integration tests verify behavior of small units together. End-to-end tests focus on real user scenarios. The document also covers tools for testing like test runners, assertion libraries, spies, and DOM mocking. It emphasizes writing tests first before coding to catch bugs early (test-driven development). Overall, the document aims to help developers understand options for testing complex UIs at scale.
The document is a manual on Java programming that covers several topics:
1. It introduces classes and objects as the fundamental programming units in Java and defines methods as collections of executable code that manipulate object data and provide class behavior.
2. It discusses various programming constructs like selection and looping statements, and casting/type conversions. Examples are provided to demonstrate if/else statements, for loops, and explicit type conversions.
3. It covers arrays as contiguous blocks of memory for storing multiple values of the same type, including how to declare and initialize one-dimensional and multi-dimensional arrays. Sample code demonstrates summing array elements and transposing a matrix.
Java was developed in 1991 by Sun Microsystems as part of the Green project. A team member named James Gosling grew dissatisfied with C++ and created a new language called Oak, which was later renamed to Java in 1995 by Sun Microsystems. Java is an object-oriented language that is platform independent, robust, reliable, secure, and has features like compilation to bytecode, dynamic binding, and multithreading.
The document discusses the building blocks of a SystemVerilog testbench. It describes the program block, which encapsulates test code and allows reading/writing signals and calling module routines. Interface and clocking blocks are used to connect the testbench to the design under test. Assertions, randomization, and other features help create flexible testbenches to verify design correctness.
ACEP Magazine edition 4th launched on 05.06.2024Rahul
This document provides information about the third edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
International Conference on NLP, Artificial Intelligence, Machine Learning an...gerogepatton
International Conference on NLP, Artificial Intelligence, Machine Learning and Applications (NLAIM 2024) offers a premier global platform for exchanging insights and findings in the theory, methodology, and applications of NLP, Artificial Intelligence, Machine Learning, and their applications. The conference seeks substantial contributions across all key domains of NLP, Artificial Intelligence, Machine Learning, and their practical applications, aiming to foster both theoretical advancements and real-world implementations. With a focus on facilitating collaboration between researchers and practitioners from academia and industry, the conference serves as a nexus for sharing the latest developments in the field.
Literature Review Basics and Understanding Reference Management.pptxDr Ramhari Poudyal
Three-day training on academic research focuses on analytical tools at United Technical College, supported by the University Grant Commission, Nepal. 24-26 May 2024
We have compiled the most important slides from each speaker's presentation. This year’s compilation, available for free, captures the key insights and contributions shared during the DfMAy 2024 conference.
Low power architecture of logic gates using adiabatic techniquesnooriasukmaningtyas
The growing significance of portable systems to limit power consumption in ultra-large-scale-integration chips of very high density, has recently led to rapid and inventive progresses in low-power design. The most effective technique is adiabatic logic circuit design in energy-efficient hardware. This paper presents two adiabatic approaches for the design of low power circuits, modified positive feedback adiabatic logic (modified PFAL) and the other is direct current diode based positive feedback adiabatic logic (DC-DB PFAL). Logic gates are the preliminary components in any digital circuit design. By improving the performance of basic gates, one can improvise the whole system performance. In this paper proposed circuit design of the low power architecture of OR/NOR, AND/NAND, and XOR/XNOR gates are presented using the said approaches and their results are analyzed for powerdissipation, delay, power-delay-product and rise time and compared with the other adiabatic techniques along with the conventional complementary metal oxide semiconductor (CMOS) designs reported in the literature. It has been found that the designs with DC-DB PFAL technique outperform with the percentage improvement of 65% for NOR gate and 7% for NAND gate and 34% for XNOR gate over the modified PFAL techniques at 10 MHz respectively.
Introduction- e - waste – definition - sources of e-waste– hazardous substances in e-waste - effects of e-waste on environment and human health- need for e-waste management– e-waste handling rules - waste minimization techniques for managing e-waste – recycling of e-waste - disposal treatment methods of e- waste – mechanism of extraction of precious metal from leaching solution-global Scenario of E-waste – E-waste in India- case studies.
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...University of Maribor
Slides from talk presenting:
Aleš Zamuda: Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapter and Networking.
Presentation at IcETRAN 2024 session:
"Inter-Society Networking Panel GRSS/MTT-S/CIS
Panel Session: Promoting Connection and Cooperation"
IEEE Slovenia GRSS
IEEE Serbia and Montenegro MTT-S
IEEE Slovenia CIS
11TH INTERNATIONAL CONFERENCE ON ELECTRICAL, ELECTRONIC AND COMPUTING ENGINEERING
3-6 June 2024, Niš, Serbia
Understanding Inductive Bias in Machine LearningSUTEJAS
This presentation explores the concept of inductive bias in machine learning. It explains how algorithms come with built-in assumptions and preferences that guide the learning process. You'll learn about the different types of inductive bias and how they can impact the performance and generalizability of machine learning models.
The presentation also covers the positive and negative aspects of inductive bias, along with strategies for mitigating potential drawbacks. We'll explore examples of how bias manifests in algorithms like neural networks and decision trees.
By understanding inductive bias, you can gain valuable insights into how machine learning models work and make informed decisions when building and deploying them.
A review on techniques and modelling methodologies used for checking electrom...nooriasukmaningtyas
The proper function of the integrated circuit (IC) in an inhibiting electromagnetic environment has always been a serious concern throughout the decades of revolution in the world of electronics, from disjunct devices to today’s integrated circuit technology, where billions of transistors are combined on a single chip. The automotive industry and smart vehicles in particular, are confronting design issues such as being prone to electromagnetic interference (EMI). Electronic control devices calculate incorrect outputs because of EMI and sensors give misleading values which can prove fatal in case of automotives. In this paper, the authors have non exhaustively tried to review research work concerned with the investigation of EMI in ICs and prediction of this EMI using various modelling methodologies and measurement setups.
A review on techniques and modelling methodologies used for checking electrom...
AJP
1. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 1 of 38
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in themodel
answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may tryto
assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given moreImportance
(Not applicable for subject English and Communication Skills).
4) While assessing figures, examiner may give credit for principal components indicated in
thefigure. The figures drawn by candidate and model answer may vary. The examiner may
givecredit for anyequivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed
constantvalues may vary and there may be some difference in the candidate’s answers and model
answer.
6) In case of some questions credit may be given by judgement on part of examiner of
relevantanswer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on
equivalentconcept.
1. A) Attempt any three of the following: Marks 12
a) List any eight controls from java. awt package. 4
(Each ½ Mark any Eight)
Ans:
1. Label
2. Button
3. Checkbox
4. Choice list
5. List
6. Scrollbar
7. Text Field
8. Text Area
9. Menu and Menubar
10. Canvas
2. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 2 of 38
b) Explain use of button control in AWT with example. 4
(Defination-1 Mark, Methods-1 Mark, Example-2 Marks)
Ans: A button is a component that contains a label and that generates an event when it is pressed.
buttons are object of type Button. Button defines
Button()
Button(String str)
After a button has been created,you can set its label by calling setLabel().
You can retrieve its label by calling getLabel()
Void setLabel(String str)
String getLabel()
Example:
import java.awt.*;
import java.applet.*;
/*<applet code=”MyButtonDemo” width=250
Height=150>
</applet>
public class mybuttondemo extends Applet
{
Button ok,cancel,apply;
public void init()
{
ok= new Button(“ok”);
cancel= new Button(“cancel”);
apply= new Button(“apply”);
add(ok);
add(cancel);
add(apply);
}
}
3. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 3 of 38
c) List four differences between TCP and UDP. 4
(Any four Points -1 Mark each)
Ans:
TCP UDP
It is connection Oriented It is connectionless
It gives acknowledgement It does not give acknowledgement
It is reliable It is unreliable
It is use to transfer for large amount of
data
It is use to transfer for small amont of data
Transmission seed is low Transmission seed is High
TCP header size is 20 bytes UDP Header size is 8 bytes
TCP does error checking
UDP does error checking, but no recovery
options
d) Write three factory method of InetAddress class. 4
(Three method- 4 Marks)
Ans: The Inet class has no invisible constructor.
To create an Inet address object,you have to use one of the available factory methods.
Factory methods are merely aconvention whereby static methods in a class returns an instance of
that class.
Three commonly used InetAddress factory methods are
1) static InetAddress getLocalHost()
throws unKnownHostException
This method simply returns the InetAddress object that represents the local host.
2) static InetAddress getByName(String hostname)
throws unKnownHostException
This method simply returns the InetAddress for a host name passed to it.
3) static InetAddress[] getAllByName(String hostname)
throws unKnownHostException
which takes an IPaddress and returns an InetAddress object.
4. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 4 of 38
B) Attempt any one of the following: Marks 6
a) List various types of JDBC drives. Explain JDBC-ODBC bridge driver.
(Types-2 Marks, Bridge driver diagram - 1 Marks, Discription-3 Marks)
Ans: Type 1: JDBC-ODBC bridge
Type 2: JDBC-native API
Type 3:100% pure java, JDBC network
Type 4:100% java
JDBC-ODBC bridge
5. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 5 of 38
This category works with ODBC drivers supplied by your database vendor or a third party.
To use the bridge, you must first have an ODBC driver specifically for you database and
additional software that you need for connectivity.
Using ODBC also requires configuring on your system a DNS that represents the target database.
Advantages
1) It offers the ability to connect to almost all databases on almost all platforms.
2) It may be the only way to gain access to some low and desktop database and application
Disadvantages
1) ODBC driver must also be loaded on the target machine.
2) Translation between JDBC and ODBC affects performance.
b) Write a program to demonstrate the use of JScrollpane in swing.
(Any 1 program- Applet tag-2mark, correct logic-4 Marks, Synatax-2 Marks)
Ans: import java.awt.*;
import javax.swing.*;
/*<applet code=”JScrollPaneDemo” width=350
Height=250>
</applet>
*/
Public class JscrollPaneDemo extends JApplet
Public void init()
{
Container contentPane= get ContentPane();
contentPane.setLayout(new BorderLayout());
JPanel jp = new JPanel();
jp.setLayout(new GridLayout(20,20));
int b=0;
for(int i=0;i<20;i++){
jp.add(new JButton(“Button”+b);
6. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 6 of 38
++b;
}
}
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h= ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp= new JScrollPane(jp,v,h);
contentPane.add(jsp,BorderLayout.CENTER);
}
}
2. Attempt any two of the following: Marks 16
a) Write an application program making use of menu and menu bar class. 8
(Applet tag – 1Mark, correct logic to add menu and menubar - 5 Marks, Synatax-2 Marks)
Ans: import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code=” MenuFrame” width=350
Height=250>
</applet>
*/
class MenuFrame extends Frame implements ActionListener
{
String msg=””;
MenuFrame(String title)
{
super(title);
MenuBar mbar= new menuBar();
setMentBar(mbar);
Menu file=new Menu(“File”);
MenuItem item1,item2,item3,item4,item5;
7. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 7 of 38
item1= new MenuItem (“New”);
item2= new MenuItem (“open”);
item3= new MenuItem (“close”);
item4= new MenuItem (“-”);
item5= new MenuItem (“Quit”);
file.add(item1);
file.add(item2);
file.add(item3);
file.add(item4);
file.add(item5);
mbar.add(file);
MenuItem item6,item7,item8,item9;
item6= new MenuItem (“cut”);
item7= new MenuItem (“copy”);
item8= new MenuItem (“paste”);
item9= new MenuItem (“-”);
edit.add(item6);
edit.add(item7);
edit.add(item8);
edit.add(item9);
mbar.add(edit);
item1.addActionListener(this);
item2.addActionListener(this);
item3.addActionListener(this);
item4.addActionListener(this);
8. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 8 of 38
item5.addActionListener(this);
item6.addActionListener(this);
item7.addActionListener(this);
item8.addActionListener(this);
item9.addActionListener(this);
}
Public void paint(Graphics g)
{
g.drawString(msg,10,200);
}
public void actionPerformed(ActionEvent e)
{
msg= “You have selected ”+ e.getActionCommand();
repaint();
}
public static void main(String args[])
{
MenuFrame m=new MenuFrame(“MyMenu”);
m.setVisible(true);
m.setSize(100,200);
}
}
9. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 9 of 38
b) Give the use of Server Socket and Socket class. Describe the steps that are 8
required to establish communication between client and server sockets.
(Use-2 Marks each class, Steps-4 Marks)
Ans: Server socket:
A Server Socket handles the requests and sends back an appropriate reply. The actual tasks that a
server socket must accomplish are implemented by an internal SocketImpl instance. A server
socket waits for requests to come in over the network. It performs some operation based on that
request, and then possibly returns a result to the requester. The actual work of the server socket is
performed by an instance of the SocketImpl class. An application can change the socket factory
that creates the socket implementation to configure itself to create sockets appropriate to the local
firewall.
Client socket:
we have used the class named ClientSocketInformation.java that implement the constructor of
the Socket class passing two arguments as hostName and TIME_PORT. This program throws an
IOException for the exception handling. This exception is thrown to indicate an I/O problem of
some sort occurred. Here, we are going to explore a method to retrieve the host name of the local
system in a very simple way. In this way we find out the Local address, Local host information,
reuseAddress, and address of the local system in a very simple manner.
Steps to connect
Using TCP, socket provides the communication mechanism between two computers. A client
program creates a socket at its end of the communication and attempts to connect that socket to a
server.
The following is the lists of sequential steps which occur when establishing a TCP connection
between client socket and server socket.
1. The server initiates a Server Socket object and mentions which port number communication is
to occur on.
2. The server invokes the accept () method of the ServerSocket class. This method does the wait
till a client gets connected to the server on the given port.
10. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 10 of 38
After the waiting stages of server, a client instantiates a Socket object. It also specifies the
server name and port number to which it gets connected.
3. The constructor of the Socket class tries to connect the client to the specified server and port
number. If the communication is established, the client has a Socket object which is capable
of communicating with the server.
4. On server side, the accept () method returns a reference to a new socket on the server that is
connected to the client’s socket.
Once the connection are established, communication occur using I/O streams. Each socket has
both an Outputstream and InputStreams
As we know that the TCP is a two way communication protocol. So data can be sent across
both streams at the same time
Two constructors used to create client socket:
Socket (String hostname,int port)
Creates a socket connection the localhost to name host and port.
Socket(InetAddress ipAddress,int port)
Creates a socket using pre existing InetAddress object and a port.
A socket can be examined at any time for the address and port information associated with it.
InetAddress getInetAddress()
Int getPort()
Int getLocalPort()
Once the socket object has been created, it can be examined to gain access to i/p and o/p streams
associated with it.
Example : (optional)
import java.net.*;
import java.io.*;
class abc{
public static void main(String args[])throws Exception{
11. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 11 of 38
int c;
Socket s=new socket(“interic.net”,43);
InputStream in=s.getInputStream();
OutputStream out=s.getOutputStream();
String str=(args.length==0?”Osborne.com”);
byte buf[]=str.getBytes();out.write(buf);
while((c=in.read())!=-1){
System.out.println({char)c);
}
s.close();
}
}
c) Give sequential steps to use JTabbedPane in an Applet with example.
(Steps- 4Marks, any one Example- 4Marks)
Ans: The general procedure to use a tabbed pane in an applet is
1) Create a JtabbedPane object.
2) Call addTab() to add to the pane.
3) Repeat step 2 for each tab.
4) Add the tabbed pane to the content pane of the applet.
Example:
import javax.swing.*;
/*<applet code=”JTabbedPaneDemo” width=350
Height=250>
</applet>
*/
public class JTabbedPaneDemo extends JApplet
{
12. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 12 of 38
public void init()
{
JTabbedPane jtp= new JTabbedPane();
jtp.addTab(“cities”,new citiesPanel());
jtp.addTab(“colors”,new colorsPanel());
jtp.addTab(“Flavour”,new flavourPanel());
getContentPane().add(jtp);
}
}
class citiespanel extends JPanel
{
Public citiesPanel()
{
JButton b1=new Button(“New York”);
add(b1);
JButton b2=new Button(“london”);
add(b2);
}
}
class colorpanel extends JPanel
{
Public colorPanel()
{
JCheckBox cb1=new JCheckBox(“red”);
add(cb1);
JCheckBox cb2=new JCheckBox (“green”);
add(cb2);
}
}
class flavourpanel extends JPanel
{
13. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 13 of 38
public flavourPanel()
{
JComboBox b=new JComboBox();
jcb.addItem(“vanilla”);
jcb.addItem(“chocolate”);
add(jcb);
}
}
3. Attempt any four of the following: Marks 16
a) Example the use of prepared statement with example. 4
(Explanation-2 Marks, Example-2 Marks)
Ans: PrepareStatement ()
The preparedStatement() method creates a PreparedStatement object and returns it as a return
value. The Prepared statement object is used to execute dynamic SQL statement against the
database.A dynamic SQL statement is a statement in which some of the parameters in the
statement are unknown when the statement is created. The parameter is placed into the SQL
statement as they are determined by the application. When all the parameters are specified for the
SQL statement, the dynamic SQL statement will be executed just as a static statement is executed.
To create a dynamic SQL statement that takes a first name and last name as parameters, use the
following code:
try
{
String sql=”Select * from temployee” + “where Firstname=?” + “and Lastname=?”;
PreparedStatement p=connection.preparedStatement(sql);
}
Catch(SQLException e)
{
}
14. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 14 of 38
b) List any four differences between AWT and swing. 4
(Any four points – 1 Mark each)
Ans:
Swing AWT
It uses javax.swing package. It uses java.applet package.
It uses JApplet class It uses Applet class
Swing is light weight component AWT is heavy weight component
It does not have add() method to add
control.
It has add() method to add control.
AWT provides less features than
swing
Swing has variety of component &
features which is not in AWT
Awt has huge collection of classes &
interfaces
Swing has bigger collection of classes
& interfaces than AWT
AWT has predefined formats of
appearance & behavior of component
Swing provides a facility of different
appearance & behavior of the same
component
c) List four interfaces in javax.servlet package. 4
(Any four points – 1 Mark each)
Ans: Following are the interfaces in javax.servlet package:
1. Servlet: All servlets must implement the Servlet interface. It declares the init( ), service( ),
and destroy( ) methods that are called by the server during the life cycle of a servlet.
2. ServletConfig: The ServletContextinterface is implemented by the server. It enables servlets
to obtain information about their environment.
3. ServletContext: The ServletContextinterface is implemented by the server. It enables
servlets to obtain information about their environment.
4. ServletRequest: The ServletRequestinterface is implemented by the server. It enables a
servlet to obtain information about a client request.
5. ServletResponse : The ServletResponseinterface is implemented by the server. It enables a
servlet to formulate a response for a client.
6. SingleThreadModel: This interface is used to indicate that only a single thread will execute
the service( ) method of a servlet at a given time. It defines no constants and declares no
methods.
15. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 15 of 38
d) Give the use of ImageIcon class with example. 4
(Explanation – 2 Marks, Example- 2 Marks)
Ans: In Swing, icons are encapsulated by the ImageIconclass, which paints an icon from an
image. Two of its constructors are shown here:
ImageIcon(String filename)
ImageIcon(URL url)
The first form uses the image in the file named filename. The second form uses the
image in the resource identified by url.
The ImageIconclass implements the Icon interface that declares the methods
As follows:
Method Description
intgetIconHeight( ) Returns the height of the iconin pixels.
intgetIconWidth( ) Returns the width of the iconin pixels.
voidpaintIcon(Component comp, Graphics g,intx, inty)Paints the icon at position x, y onthe
graphics context g. Additionalinformation about the paintoperation can be provided in comp.
Example:
import java.awt.*;
import javax.swing.*;
<applet code="JLabelDemo" width=250 height=150>
</applet>
*/
public class JLabelDemo extends JApplet {
public void init() {
// Get content pane
Container contentPane = getContentPane();
// Create an icon
ImageIcon ii = new ImageIcon("france.gif");
// Create a label
JLabeljl = new JLabel("France", ii, JLabel.CENTER);
// Add label to the content pane
contentPane.add(jl);
16. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 16 of 38
}
}
e) Give the use of URL class along with syntax of constructors of URL class. 4
(Use - 2 Marks, Any two Constructor - 1 Mark each)
Ans: The URL provides a reasonably intelligible form to uniquely identify or address information on the
Internet. URLs are ubiquitous; every browser uses them to identify information on the Web. In
fact, the Web is really just that same old Internet with all of its resources addressed as URLs plus
HTML
Java's URL class has several constructors. One commonly used form specifies the URL with a
string that is identical to what you see displayed in a browser:
1. URL(String urlSpecifier)
The next two forms of the constructor allow you to break up the URL into its componentparts:
2. URL(String protocolName, String hostName, intport, String path)
3. URL(String protocolName, String hostName, String path)
Another frequently used constructor allows you to use an existing URL as a referencecontext and
then create a new URL from that context. Although this sounds a littlecontorted, it's really quite
easy and useful.
4. URL(URL urlObj, String urlSpecifier)
4. A) Attempt any three of the following: Marks 12
a) Give the use of following methods of statement interface : 4
i) executeQuery( ) ii) execute Update ( )
(Each method – 2 Marks)
Ans: i) executeQuery()
The executeQuery() method of the statement object enables you to send SQL select statement to
the database and to receive result from the database. Executing a query in effect sends a SQL
select statement to the database and returns the appropriate results back in the Resultset object.
The executeQuery() method takes a SQL select statement as a parameter and returns a ResultSet
object that contains all the records that match the select statements criteria.
ii) executeUpdate()
17. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 17 of 38
The executeUpdate() method of the Statement object enables you to execute SQL update
statements such as delete, insert and update. The method takes a String containing the SQL update
statement and returns an integers that determines how many records were affected by the SQL
statement.
b) Define Layout Manager. Describe the use of GridLayout Manager. 4
(Layout manager- 2 Marks, Use-2 Marks)
Ans: Each Container object has a layout manager associated with it. A layout manager
is an instance of any class that implements the LayoutManagerinterface. The layout
manager is set by the setLayout( ) method. If no call to setLayout( ) is made, then the
default layout manager is used. Whenever a container is resized (or sized for the first
time), the layout manager is used to position each of the components within it.
The setLayout( ) method has the following general form:
voidsetLayout(LayoutManagerlayoutObj)
GridLayoutManager:
GridLayout lays out components in a two-dimensional grid. When you instantiate
a GridLayout, you define the number of rows and columns. The constructors
supported by GridLayoutare shown here:
GridLayout( )
GridLayout(intnumRows, intnumColumns)
GridLayout(intnumRows, intnumColumns, inthorz, intvert)
c) Explain the use of cookies with example. 4
(Explanation - 2 Marks, Example - 2 Marks any one)
Ans: Cookie is a small piece of information that is passed back and forth in the HTTP request and
response. Even though a cookie can be created on the client side using some scripting language
such as JavaScript, it is usually created by the server resource, such as a Servlet. The Cookies sent
by the server when the client requests another page from the same application. In Servlet
programming a cookie is represented by a Cookie class in the javax.servlet.http package. You can
create a cookie by calling the Cookie class constructor and passing two string objects: the name
18. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 18 of 38
and value of the cookie. For instance, the following code creates a cookie object called c1.The
cookie has the name “myCookie” and value of ”secret”:
Cookie c1=new Cookie(“myCookie”,”secret”);
You then can add the cookie to the http response using addCookie method of the
HTTPServletResponse interface:Response.addCookie(c1);
Program for Add cookies
import java.io.*;
importjavax.servlet.*;
importjavax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response)
throwsServletException, IOException
{
// Get parameter from HTTP request.
String data = request.getParameter("data");
// Create cookie.
Cookie cookie = new Cookie("MyCookie", data);
// Add cookie to HTTP response.
response.addCookie(cookie);
// Write output to browser.
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
19. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 19 of 38
pw.close();
}
}
OR
Program for Get Cookies
import java.io.*;
importjavax.servlet.*;
importjavax.servlet.http.*;
public class GetCookiesServlet extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)
throwsServletException, IOException
{
// Get cookies from header of HTTP request.
Cookie[] cookies = request.getCookies();
// Display these cookies.
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>");
for(inti = 0; i<cookies.length; i++)
{
String name = cookies[i].getName();
String value = cookies[i].getValue();
pw.println("name = " + name +
"; value = " + value);
}
20. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 20 of 38
pw.close();
}
}
d) Give steps to create simple servlet with example. 4
(Steps- 2 Marks, Any one Example – 2 Marks)
Ans: Steps 1) Write a java servet code;
Steps 2) Compile Servet by setting classpath with servlet-api library.
Step 3) Copy the .class servlet file in web apps classpath directory.
Steps 4) Open the web.xml, open it and add servlet tag and sevlet mapping tag.
Steps 5) Start web server(apche tomcat);
Steps 6) Browse servlet using java compatible browser like IE .
Example shows to start, create a file named WelcomeServlet.java that contains the following
program.
import java.io.*;
importjavax.servlet.*;
public class WelcomeServletDemo extends GenericServlet
{
public void service(ServletRequestrequest,ServletResponse response) throws
ServletException,IOException
{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>Welcome to Servlet");
pw.close();
}
}
21. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 21 of 38
B) Attempt any one of the following: Marks 6
a) Describe the two –tier and three –tier database design of JDBC API with neat diagram.
(Explanation of Two-tier-2 Marks and Three-tier-2 Marks, Diagram – 1 Mark each)
Ans: Two Tier Architecture:
In a two tier model a java application is designed to interact directly with the database.
Application functionality is divided into these two layers:
1) Application Layer: Including the JDBC driver, business logic and user interface
2) Database Layer: including RDBMS
The interface to the database is handled by the Java Database Connectivity(JDBC) Driver
appropriate to the particularly database management system being accessed. The JDBC Driver
passes SQL statements to the database and returns the results of those statements to the
application.
A client/server configuration is the special case of the two tier model where the database is
located on another machine referred to as the server. The application runs on the client machine
which is connected to the server over a network. Commonly the network is an Intranet using
dedicated database servers to support multiple clients but it can just as easily be the internet.
Three Tier Architecture:-
In the three tier model, the client typically sends requests to an application server, forming the
middle tier. The application server interprets these requests and formats the necessary SQL
statement to fulfill
22. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 22 of 38
These requests, and sends them to the database. The database process the SQL statements and
sends result back to the application server, which then sends them to the client.
Following are some advantages of Three-tier architecture:
1. Performance can be improved by separating the application server and database server
2. Business logic is clearly separated from the database.
3. Client application can use a simple protocol such as CGI to access services.
The three-tier model show in following fig is a common in web application. In this scenario, the
client tier is frequently implemented in a browse on a client machine, the middle tier is
implemented in a web server with a Servlet engine and the database management system runs on
a dedicated database server.
Following are the main components of three tier architecture
1. Client Tier: - Typically, this is thin presentation layer that may be implemented using a web
browser
2. Middle Tier :- This tier handles the business or application logic . This may be implemented
using a Servlet engine such as Tomcat or an application server such as JBOSS. The JDBC
driver also resides in this layer.
3. Data source layer: This component includes the RDBMS
23. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 23 of 38
b) Write servlet which shows how many times user has visited the page in session.
(Any Correct Logic –4 Marks, Syntax – 2 Marks)
Ans: import java.io.*:
import javax.servlet.*;
import javax.servlet.http.*;
public class Session Travker extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException
{
res.setContentType(“text/html”);
PrintWriter out = res.getWriter();
HttpSession session = req.getSession(true);
Integer count= (Integer)session.getValue(“tracker.count”);
if(count== null) count=new Interger(1);
else count = new Interger(count intValue() +1);
session.putValue(“tracker.count”,count);
out.println(“<HTML><HEAD><TITLE>Session Tracker</TITLE></HEAD>”);
out.println(“<BODY><H1>Session Tracking Demo</H1>”);
out.println(“You have visited this page” +count +((count.intValue() == 1)?”time.” :
“times.”));out.prinln(<P>”);
out.println(“<H2>Sesssion data:</H2>”);
String[] names = session.getValueNames();
for(int i=0; i< names.length; i++)
{
24. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 24 of 38
out.println(names[i] + “ : ” + session.getvalue(names[i])+ “<BR>”);
}
out.println(“<BODY></HTML>”);
}
}
5. Attempt any two of the following: Marks 16
a) Write a program to display all records from Employee table from database using
JDBC.
(Assume suitable data for table- Load driver, create connection, execute Query - 1 Mark
each, Display data- 3 Marks, Syntax – 2 Marks)
Ans: import java.sql.*;
import java.sql.Statement;
import java.applet.*;
import java.awt.*;
public class DisplayTable
{
public static void main( String args[])
{
RsultSet rs;
Connection conn;
try
{
String s1;
Class.forName("sun .jdbc.odbc.JdbcOdbcDriver");
System.out.println("Connecting to a selected database...");
String url=”jdbc:odbc:abc”;
conn = DriverManager.getConnection(DB_URL, USER, PASS);
System.out.println("Connected database successfully...");
25. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 25 of 38
System.out.println("Creating statement...");
stmt = conn.createStatement();
sql = "SELECT * FROM Employee";
ResultSet rs = stmt.executeQuery(sql);
// Tables fields assumed are id, first, last, age
while(rs.next()){
int id = rs.getInt("id");
int age = rs.getInt("age");
String first = rs.getString("first");
String last = rs.getString("last");
System.out.print("ID: " + id);
System.out.print(", Age: " + age);
System.out.print(", First: " + first);
System.out.println(", Last: " + last);
}
rs.close();
}catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}catch(Exception e){
//Handle errors for Class.forName
e.printStackTrace();
}finally{
//finally block used to close resources
try{
if(stmt!=null)
conn.close();
}catch(SQLException se){
}
26. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 26 of 38
}
}
}
b) Define the term:
i) Reserved socket ii) proxy server
iii) Datagram iv) URL connection 4
(Each term- 2 Marks)
Ans: i) Reserved socket
A socket is one end-point of a two-way communication link between two programs running on
the network. Socket classes are used to represent the connection between a client program and a
server program.
Reserved socket : The socket which are reserved for specific protocols for communication
purpose are known as reseved sockets.
TCP/IP uses or reserves the lower 1024 ports for specific protocols.
Example: port number 23 is for Telnet ,25 is for smtp, 21 is for ftp, 13 for daytime, 110 for pop3
and so on. Protocol decides how a client should interact with the port.
ii) Proxy server
A proxy server is a computer that offers a computer network service to allow clients to make
indirect network connections to other network services. A client connects to the proxy server,
then requests a connection, file, or other resource available on a different server. The proxy
provides the resource either by connecting to the specified server or by serving it from a cache. In
some cases, the proxy may alter the client's request or the server's response for various purposes.
Purposes of the proxy servers:
To keep machines behind it anonymous, mainly for security.
To speed up access to resources (using caching). Web proxies are commonly used to
cache web pages from a web server.
To prevent downloading the same content multiple times (and save bandwidth).
To log / audit usage, e.g. to provide company employee Internet usage reporting.
27. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 27 of 38
To scan transmitted content for malware before delivery.
To scan outbound content, e.g., for data loss prevention
iii) Datagram
Datagrams are bundles of information passed between machines. They are somewhat like a hard
throw from a well-trained but blindfolded catcher to the third baseman. Once the datagram has
been released to its intended target, there is no assurance that it will arrive or even that
someone will be there to catch it. Likewise, when the datagram is received, there is no
assurance that it hasn’t been damaged in transit or that whoever sent it is still there to receive a
response.
Java implements datagrams on top of the UDP protocol by using two classes:
The DatagramPacket object is the data container, while the DatagramSocket is the mechanism
used to send or receive the DatagramPackets.
iv) URL connection
URLConnection is a general-purpose class for accessing the attributes of a remote resource.
Once you make a connection to a remote server, you can use URLConnection to inspect the
Properties of the remote object before actually transporting it locally. These attributes are
exposed by the HTTP protocol specification and, as such, only make sense for URL objects
that are using the HTTP protocol.
URLConnection defines several methods
int getContentLength( )
String getContentType( )
long getDate( )
long getExpiration( )
String getHeaderField(int idx)
long getLastModified( )
28. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 28 of 38
c) Write a program to display three text fields and a button below to all an Applet. Insert
the integer valuer from three text fields. After pressing the button the background colour
of applet will be changed as per the RGB combination of the values given in the text field.
(Correct logic - 6 Marks, Syntax - 2 Marks)
4
Ans: import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code=”Clr.class” width=250 heigth=250><applet>*/
public class Clrextends Applet implements ActionListener
{
int r, g, b;
TextField t1,t2,t3;
Button b1;
Color c1;
public void init()
{
t1= new TextField(5);
t2= new TextField(8);
t3= new TextField(11);
b1 = new Button(“ Set Color”);
29. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 29 of 38
add(t1);
add(t2);
add(t3);
add(b1);
b1.addActionListener(this);
}
public void void paint( )
{
setBackground(c1);
}
public void actionPerformed(ActionEvent ae)
{
r=Integer.parseInt(t1.getText());
g=Integer.parseInt(t2.getText());
b=Integer.parseInt(t3.getText());
c1= new Color(r,g,b);
repaint();
}
}
30. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 30 of 38
6) Attempt any four of the following: Marks 16
a) How to check, how many fonts are available in the computer system? 4
Explain with example.
(Explanation -2 Marks, Example-2 Marks)
Ans: When working with fonts, often you need to know which fonts are available on your machine. To
ontain this information, you can use the getAvailableFontFamilyNames() method defined by the
GraphicsEnvironment class.It is shown here:
String[ ] getAvailableFontFamilyNames( )
This method returns an array of string that contains the names of the available font families.
Since, this methods is members of GraphicsEnvironment, you need a GraphicsEnvironment
reference to call it.You can obtain this reference by using the getlocalGrahicsEnvironmet() static
method, which is derfined by GraphicsEnvironment.It is shown here:
static GraphicsEnvironment getLocalGraphicsEnvironment( )
Here, is an applet that shown how to obtain the names of the available font families.
/*
<applet code=”AllFonts” width=500 height=100>
</applet>
*/
import java.applet.*;
import java.awt.*;
public class AllFonts extends Applet
{
public void paint(Graphics g)
{
string fonts= “ ”;
stirng allFontsList[];
31. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 31 of 38
GraphicsEnvironment t = GraphicsEnvironment.getLocalGraphicsEnvironment();
allFontList = t.getAvailableFontFamilyNames();
for(int i= 0; i< allFontsList.length; i++)
fonts= fonts + allFontList[i] + “ ”;
g.drawString(msg,4,16);
}
}
b) Explain following check box class methods with appropriate example. 4
i) Void setLable (String str) ii) Boolean getState ( )
(Explanation of each method-1 Marks, Example-2 Marks)
Ans:
i) void setLable(String str)
This method is used to set the label of check box
ii) Boolean getState()
This method is used to retrieve the current state of a check box. It returns the value either true or
false depends on check box is selected or not.
Example:
// Demonstrate check boxes.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="CheckboxDemo" width=250 height=200>
</applet>
*/
public class CheckboxDemo extends Applet implements ItemListener {
String msg = "";
32. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 32 of 38
Checkbox winXP, winVista, solaris, mac;
public void init() {
winXP = new Checkbox("Windows XP", null, true);
mac = new Checkbox();
mac.setLable(“Mac OS”);
add(winXP);
add(mac);
winXP.addItemListener(this);
mac.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie) {
repaint();
}
// Display current state of the check boxes.
public void paint(Graphics g) {
msg = "Current state: ";
g.drawString(msg, 6, 80);
msg = " Windows XP: " + winXP.getState();
g.drawString(msg, 6, 100);
msg = " Mac OS: " + mac.getState();
g.drawString(msg, 6, 120);
}
}
33. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 33 of 38
c) Explain the techniques of session tracking /management.
(Any four techniques with explanation- 1 Mark each)
Ans: Session tracking Techniques:
1. User Authorization
Users can be authorized to use the web application in different ways. Basic concept is that the
user will provide username and password to login to the application. Based on that the user can
be identified and the session can be maintained.
2. Hidden Fields
<INPUT TYPE=”hidden” NAME=”technology” VALUE=”servlet”>
Hidden fields like the above can be inserted in the webpages and information can be sent to the
server for session tracking. These fields are not visible directly to the user, but can be viewed
using view source option from the browsers. This type doesn’t need any special configuration
from the browser of server and by default available to use for session tracking. This cannot be
used for session tracking when the conversation included static resources lik html pages.
3. URL Rewriting
Original URL: http://server:port/servlet/ServletName
ewritten URL: http://server:port/servlet/ServletName?sessionid=7456
When a request is made, additional parameter is appended with the url. In general added
additional parameter will be sessionid or sometimes the userid. It will suffice to track the
session. This type of session tracking doesn’t need any special support from the browser.
Disadvantage is, implementing this type of session tracking is tedious. We need to keep track of
the parameter as a chain link until the conversation completes and also should make sure that,
the parameter doesn’t clash with other application parameters.
34. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 34 of 38
4. Cookies
Cookies are the mostly used technology for session tracking. Cookie is a key value pair of
information, sent by the server to the browser. This should be saved by the browser in its space
in the client computer. Whenever the browser sends a request to that server it sends the cookie
along with it. Then the server can identify the client using the cookie.
In java, following is the source code snippet to create a cookie:
Cookie cookie = new Cookie (“userID”, “7456″);
res.addCookie(cookie);
5. Session tracking API
Session tracking API is built on top of the first four methods. This is inorder to help the
developer to minimize the overhead of session tracking. This type of session tracking is
provided by the underlying technology. Lets take the java servlet example. Then, the servlet
container manages the session tracking task and the user need not do it explicitly using the java
servlets. This is the best of all methods, because all the management and errors related to
session tracking will be taken care of by the container itself.
d) Give sequential steps for JTree in swing with example.
(Steps- 2 Marks, any small Example- 2 Marks)
Ans: Steps for JTree:
Atree is a component that presents a hierarchical view of data. The user has the ability to
expand or collapse individual subtrees in this display. Trees are implemented in Swing by
the JTree class.
Here are the steps to follow to use a tree:
1. Create an instance of JTree.
2. Create a JScrollPane and specify the tree as the object to be scrolled.
3. Add the tree to the scroll pane.
4. Add the scroll pane to the content pane.
35. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 35 of 38
Example:
// Demonstrate JTree.
import java.awt.*;
import javax.swing.event.*;
import javax.swing.*;
import javax.swing.tree.*;
/*
<applet code="JTreeDemo" width=400 height=200>
</applet>
*/
public class JTreeDemo extends JApplet {
JTree tree;
JLabel jlab;
public void init() {
try {
SwingUtilities.invokeAndWait(
new Runnable() {
public void run() {
makeGUI();
}
}
);
} catch (Exception exc) {
System.out.println("Can't create because of " + exc);
}
}
private void makeGUI() {
// Create top node of tree.
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Options");
// Create subtree of "A".
36. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 36 of 38
DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");
top.add(a);
DefaultMutableTreeNode a1 = new DefaultMutableTreeNode("A1");
a.add(a1);
DefaultMutableTreeNode a2 = new DefaultMutableTreeNode("A2");
a.add(a2);
// Create subtree of "B".
DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");
top.add(b);
DefaultMutableTreeNode b1 = new DefaultMutableTreeNode("B1");
b.add(b1);
DefaultMutableTreeNode b2 = new DefaultMutableTreeNode("B2");
b.add(b2);
DefaultMutableTreeNode b3 = new DefaultMutableTreeNode("B3");
b.add(b3);
// Create the tree.
tree = new JTree(top);
// Add the tree to a scroll pane.
JScrollPane jsp = new JScrollPane(tree);
// Add the scroll pane to the content pane.
add(jsp);
// Add the label to the content pane.
jlab = new JLabel();
add(jlab, BorderLayout.SOUTH);
// Handle tree selection events.
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent tse) {
jlab.setText("Selection is " + tse.getPath());
}
}
}
37. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 37 of 38
}
e) Draw and explain the life cycle of servlet.
(Explanation – 3 Marks, Diagram -1 Marks)
Ans: Three methods are central to the life cycle of a servlet.
These are init( ), service( ), and destroy( ).
They are implemented by every servlet and are invoked at specific times by the server. Let
us consider a typical user scenario to understand when these methods are called.
First, assume that a user enters a Uniform Resource Locator (URL) to a web browser.
The browser then generates an HTTP request for this URL. This request is then sent to the
appropriate server.
Second, this HTTP request is received by the web server. The server maps this request to
a particular servlet. The servlet is dynamically retrieved and loaded into the address space
of the server.
Third, the server invokes the init( ) method of the servlet. This method is invoked only
when the servlet is first loaded into memory. It is possible to pass initialization parameters
to the servlet so it may configure itself.
Fourth, the server invokes the service( ) method of the servlet. This method is called to
process the HTTP request. You will see that it is possible for the servlet to read data that has
been provided in the HTTP request. It may also formulate an HTTP response for the client.
The servlet remains in the server’s address space and is available to process any other
HTTP requests received from clients. The service( ) method is called for each HTTP request.
Finally, the server may decide to unload the servlet from its memory. The algorithms by
which this determination is made are specific to each server. The server calls the destroy( )
method to relinquish any resources such as file handles that are allocated for the servlet.
Important data may be saved to a persistent store. The memory allocated for the servlet and
its objects can then be garbage collected.
A servlet life cycle can be defined as the entire process from its creation till the destruction. The
following are the paths followed by a servlet
The servlet is initialized by calling the init () method.
38. MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
WINTER – 13 EXAMINATION
Subject Code: 12259 Model Answer Subject Name: Advanced Java Programming
____________________________________________________________________________________________________
Page 38 of 38
The servlet calls service() method to process a client's request.
The servlet is terminated by calling the destroy() method.
Finally, servlet is garbage collected by the garbage collector of the JVM.
Initialization
(Load Resources)
Services
(Accept Requests)
Destruction
(Unload Resources)
Servlet
Request
Response