Free Essay

Java Programming

In: Computers and Technology

Submitted By snasg
Words 1150
Pages 5
JAVA Programming PAPER

Q1. A template argument is preceded by the keyword ________.

► vector ► class ► template ► type*

Q2. Which of the following causes run time binding?

► Declaring object of abstract class ► Declaring pointer of abstract class ► Declaring overridden methods as non-virtual
► None of the given

Q3. A function template can not be overloaded by another function template.

► True
► False

Q4. Which of the following is the best approach if it is required to have more than one functions having exactly same functionality and implemented on different data types?

► Templates
► Overloading ► Data hiding ► Encapsulation

Q5. Identify the correct way of declaring an object of user defined template class A for char type members?

► A< char >obj; ► Aobj;
► Aobj; ► Obj A;

Q6. The user must define the operation of the copy constructor.

► True ► False

Q7. Template functions use _________ than ordinary functions.

► Greater Memory
► Lesser Memory ► Equal Memory ► None of the given options

Q8. The find() algorithm

► finds matching sequences of elements in two containers. ► finds a container that matches a specified container.
► takes iterators as its first two arguments. ► takes container elements as its first two arguments.

Q9. Compiler performs ________ type checking to diagnose type errors,

► Static ► Dynamic ► Bound ► Unbound

Q10. Which of the following is/are advantage[s] of generic programming?

► Reusability ► Writability ► Maintainability
► All of given

Q11. Vectors contain contiguous elements stored as a[an] ___.

► variable
► array ► function ► datatype

Q12. Suppose you create an uninitialized vector as follows:

vectorevec;
After adding the statment, evec.push_back(21); what will happen?

► The following statement will add an element to the start (the back) of evec and will initialize it with the value 21. ► The following statement will add an element to the center of evec and will reinitialize it with the value 21. ► The following statement will delete an element to the end (the back) of evec and will reinitialize it with the value 21. ► The following statement will add an element to the end (the back) of evec and initialize it with the value 21.

Q13. In a de-queue, (chose the best option)

► data can be quickly inserted or deleted at any arbitrary location.

► data can be inserted or deleted at any arbitrary location, but the process is relatively slow.

► datacan not be quickly inserted or deleted at either end.

► data can be inserted or deleted at either end, but the process is relatively slow.

Question No: 14 ( Marks: 1 ) - Please choose one

Algorithms can only be implemented using STL containers.

► True

► False

Question No: 15 ( Marks: 1 ) - Please choose one



► A class is a section of computer memory containing objects.

► A class is a section of the hard disk reserved for object oriented programs

► A class is the part of an object that contains the variables.

► A class is a description of a kind of object.

Question No: 16 ( Marks: 1 ) - Please choose one



► organize data.

► pass arguments to objects of classes.

► add features to existing classes without rewriting them.

► improve data-hiding and encapsulation.

Question No: 17 ( Marks: 1 ) - Please choose one

We can use "this" pointer in the constructor in the body and even in the initialization list of any class if we are careful,

► True

► False

Question No: 18 ( Marks: 1 ) - Please choose one



► private,static

► private,public

► static,public

► none of given

Question No: 19 ( Marks: 1 ) - Please choose one

Default constructor is such constructor which either has no ---------or if it has some parameters these have -------- values

► Parameter, temporary

► Null, Parameter

► Parameter, default

► non of the given

Question No: 20 ( Marks: 1 ) - Please choose one

Public methods of base class can --------- be accessed in its derived class

► directly

► inderectly

► simultaniously

► non of the given

Question No: 21 ( Marks: 1 ) - Please choose one

The type that is used to declare a reference or pointer is called its ---------

► default type

► static type

► abstract type

► reference type

Question No: 22 ( Marks: 1 ) - Please choose one

------------- members are somewhere between public and private members. They are used in inheritance

► protected

► public

► private

► global

Question No: 23 ( Marks: 1 ) - Please choose one

Which of these are examples of error handling techniques ?

► Abnormal Termination

► Graceful Termination

► Return the illegal

► all of the given

Question No: 24 ( Marks: 1 ) - Please choose one

----------------- follow try block to catch the object thrown

► catch block

► throw block

► main block

► non of the given

Question No: 25 ( Marks: 1 ) - Please choose one

Graphical representation of the classes and objects is called object model it shows -------

► Class Name only

► Class Name and attributes

► Relationships of the objects and classes

► all of the given

Question No: 26 ( Marks: 1 ) - Please choose one

Destructor can be overloaded

► True

► False

Question No: 27 ( Marks: 2 )

Describe the way to declare a template function as a friend of any class.

Template templatename
Class calssname
{
Friend void friend templatename (classnameastricconstprtclassname);
}

Question No: 28 ( Marks: 2 )

State any two reasons why the virtual methods can not be static?

1-virtual method can not be static as it is dynamic
2-as virtual method is dynamic so it works automatically that is also another reason
That virtual method can not be static.

Question No: 29 ( Marks: 2 )

Explain the statement below, vectorivec(4, 3);

Question No: 30 ( Marks: 2 )

Explain two benefits of setter functions.

1- It minimize the changes to move the objects in inconsistent states
2- You can write checks in your setter functions to check the validity of data entered by the user, for example age functions to check to calculate the age from date entered.

Question No: 31 ( Marks: 3 )

Consider the code below,

template class T1 { public: T i; protected: T j; private: T k; friend void Test(); };

This code has a template class T1 with three members i,j and k and a friend function Test(), you have to describe which member/s of T1 will be available in function Test().

public: T i; protected: T j;

Question No: 32 ( Marks: 3 )

What do you mean by Stack unwinding?
When we want to check what happens actually to the local variables in the try block when then an exception is thrown this concept is called stack unwinding.

Question No: 33 ( Marks: 3 )

Give the c++ code of case sensitive comparison function of string class.

Question No: 34 ( Marks: 5 )

What is random_iterator? What is relation between random_iterator and Vector?

Random_iterator: it provided both increment and decrement and also provide constant time methods for moving forward and backword in arbitrary sized steps. Ramdomiterator provideasentially all of the operations of ordinary c pointer arithmetic.

Vector class provide an stl style random access iterator for use with generic algorithm since neither the vactor nor the matrix classes are container classes in actuall. The iterator class is really an iterator of data object that is viewed by vector or matrix.

Question No: 35 ( Marks: 5 )

What would be the output of this code?

class mother { public: mother ()
{ cout

Similar Documents

Free Essay

Java Programming

...A Programmer’s Guide to Java™ SCJP Certification Third Edition This page intentionally left blank A Programmer’s Guide to Java™ SCJP Certification A Comprehensive Primer Third Edition Khalid A. Mughal Rolf W. Rasmussen Upper Saddle River, New Jersey • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sidney • Tokyo • Singapore • Mexico City Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United...

Words: 15086 - Pages: 61

Free Essay

Java Programming

...MTH 112 Differential Calculus MTH 122 Integral Calculus MTH 142 Vectors and Geometry PHY 124 Geometric and Wave Optics PHY 132 Electricity, Magnetism and Modern Physics PHY 192 Introductory Practical Physics II * Students are expected to offer at least one elective course per semester. Also they can only register a maximum of 25 units per semester Total Credit Unit - Compulsory Total Credit Unit - Elective Total Credit Units 20 0 20 200 Level Course Code 1st Semester GST 201 CIT 211 GST 203 CIT 213 CIT 215 CIT 237 MTH 211 MTH 213 MTH 241 MTH 281 Course Titles Unit(s) Status Nigerian Peoples and Cultures Introduction to Operating Systems Introduction to Philosophy and Logic Elementary Data Processing Introduction to Programming Languages Programming & Algorithms Introduction to Set Theory and Abstract Algebra Numerical Analysis I Introduction to Real Analysis Mathematical Methods I * Students are expected to offer at least one elective course...

Words: 911 - Pages: 4

Premium Essay

Java Programming and Inheritance

...Muhammad 1 Mikey Muhammad Date Class Mr.Radev Java Programming and Inheritance As time continues to pass, the world we now live in is dominated by the use of technology. Technology continues to advance, and it seems, as if we can’t function without it. Whether it’s the use of technology in school or work, it is everywhere and you cannot escape it. It is important for us to be able to adapt to it and learn how the new inventions work and function properly. The Internet for example is one of the most important aspects of life today. The Internet allows us to have access to everything, and have endless information at our fingertips, whether it’s through a computer screen or through the use of a cellular device, or even a watch. Some of us choose to only use this amazing tool that has been provided to us, and then some us choose to go more in depth with this tool we call the Internet and want to know how it works. Although it takes millions of programs and concepts and other factors to get the Internet working how it does, the focus of my term paper will be Inheritance in Java. In order to truly understand what the specifics of Java are, you have to start with the totality of the Java program. The Java language could easily be the most difficult to understand because there are so many components to how it works. Java is a programing language and computing platform, which is a huge part of making the Internet work. It was first released by Sun Microsystems in 1995. Without...

Words: 1332 - Pages: 6

Premium Essay

Java Programming Language Sl-275

...Sun Educational Services Java Programming Language SL-275 Sun Educational Services Java Programming Language September 1999 Copyright 1999 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, California 94303, U.S.A. All rights reserved. This product or document is protected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation. No part of this product or document may be reproduced in any form by any means without prior written authorization of Sun and its licensors, if any. Third-party software, including font technology, is copyrighted and licensed from Sun suppliers. Parts of the product may be derived from Berkeley BSD systems, licensed from the University of California. UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd. Sun, Sun Microsystems, the Sun Logo, Solstice, Java, JavaBeans, JDK, and Solaris are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the U.S. and other countries. Products bearing SPARC trademarks are based upon an architecture developed by Sun Microsystems, Inc. The OPEN LOOK and Sun Graphical User Interface was developed by Sun Microsystems, Inc. for its users and licensees. Sun acknowledges the pioneering efforts of Xerox in researching and developing the...

Words: 6064 - Pages: 25

Premium Essay

Java Programming Execution Phases

...Advanced Programing in Java Umair Javed CS-391 Java Program Development and Execution Steps Java program normally go through five phases. These are 1. 2. 3. 4. 5. Edit, Compile, Load, Verify and Execute We look over all the above mentioned phases in a bit detail. First consider the following figure that summarizes the all phases of a java program. Phase 1 Editor Disk Program is created in the editor and stored on disk. Compiler creates bytecodes and stores them on disk. Phase 2 Compiler Disk Primary Memory Phase 3 Class Loader Class loader puts bytecodes in memory. Disk Primary Memory Phase 4 Bytecode Verifier Bytecode verifier confirms that all bytecodes are valid and do not violate Java’s security restrictions. Phase 5 Primary Memory Interpreter Interpreter reads bytecodes and translates them into a language that the computer can understand, possibly storing data values as the program executes. Umair© 2005, All Rights Reserved -1- TA: Munawar Nadeem Handout 3 Advanced Programing in Java Umair Javed CS-391 Phase 1: Edit Phase 1 consists of editing a file. This is accomplished with an editor program. The programmer types a java program using the editor like notepad, and make corrections if necessary. When the programmer specifies that the file in the editor should be saved, the program is stored on a secondary storage device such as a disk. Java program file name ends with a .java extension. On Windows...

Words: 696 - Pages: 3

Free Essay

Java Programming

...Activity 1: Numbers I. Problem Create an application that will input a start value and end value. The application will start value all the members from the start to end value and all the odd and even. II. Analysis Input Variable Data Type Description SV Integer Starting Value EV Integer End Value Output Variable NOS Integer Numbers OD Integer Odd numbers EV Integer Even numbers III. Output Layout IV. Codes import java.util.Scanner; public class EvenOdd { public static void main (String[]args) { int a; int b; Scanner in = new Scanner (System.in); System.out.print ("Starting Value: "); a=in.nextInt(); System.out.print ("End Value: "); b=in.nextInt(); System.out.println("number\t"+"odd\t"+"even\t"); for(int i=a; i<=b;i++) { System.out.print(i); if(i%2==0) { System.out.println("\t\t"+i );//even } else { System.out.println("\t"+i); //odd } } } } Activity 2: Transaction I. Problem Create an application that will transact the following item codes with looping and will print a receipt. II. Analysis Input Variable Data Type Description A Integer Letter A Price B Integer Letter B Price C Integer Letter C Price D Integer Letter D Price E Integer Letter E Price q Integer Quantity tno Integer ...

Words: 1321 - Pages: 6

Free Essay

Java Programming

...Encapsulation is whereby variables, functions are protected from being accessed by other codes outside the class. This helps manage the code being protected and has least if any impact on other parts of a program if change was to occur in the protected code. Encapsulation is important in java due to its flexibility and it is easy to change with new requirement, the class has total control over what is stored in its field, one part of the code can be changed and the rest of the would not be affected and also encapsulation is useful since it is easy to maintain. Both the mutator and accessor method are used to enforce data encapsulation where their jobs is returning and setting the value state of an object. Mutator method is used to set the private field value. It is denoted by using set at the beginning of the method name. Example of a mutator method would be public void setSchool (String school). Accessor method is used to return the private field value. It is denoted by using get at the beginning of the method name. An example of accessor method would be public String getFirstName () Implicit parameter is the object on which the method is invoked whereas explicit parameter is the parameter of the method other than the object the method is invoking and is enclosed in a parentheses. To access an explicit parameter variable inside the method refer the parameter variable by its name. To illustrate what is an implicit and explicit parameter we use the following code: Person...

Words: 498 - Pages: 2

Premium Essay

Intro to Programming Usin Java

...Introduction to Programming Using Java Course Specifications Course length: 1.0 day(s) Course Description Course Objective: You will learn the basic concepts of programming using Java as the tool for learning. Target Student: This course is intended for students with no prior academic background in a field other than computer science or programming, who wish to embark on a course of study that will prepare them for employment as professional software developers. Students who interact on a business basis with software development professionals and need to improve communication through better understanding of the concepts and terminology used by professional programmers will also benefit equally. Prerequisites: Students should be familiar with using personal computers with a mouse and keyboard. Basic typing skills are mandatory. Students should be comfortable in the use of the Windows 2000, Windows XP, Windows Vista environment, or Windows 7 environment. To ensure your success in this course, we recommend that you take the following Element K courses or have equivalent experience: Microsoft Windows Vista: Level 1Microsoft Windows XP Professional: Level 1 Course Objectives Upon successful completion of this course, students will be able to: · explore various programming concepts. · create simple programs. · use methods to define the behavior of classes. · implement the object-oriented methodology. · handle errors in a program. Course Content Lesson 1: Introduction...

Words: 323 - Pages: 2

Free Essay

Assignment and Essay.... Others)Information Technology (Programming/ Languages (Java, C++, Vb,.Net, & Etc)/Database Design/ Computer Networking/ System Analysis/ Project Management/Project Development/ It & Society/ and.

...ASSIGNMENT and ESSAY. ... others)Information Technology (Programming/ Languages (Java, C++, VB, .NET, & etc)/Database Design/ Computer Networking/ System Analysis/ Project Management/Project Development/ IT & Society/ and. - NET programmers continue to struggle with the complexities of a hybrid managed/unmanaged environment. ..... Sorry, I had to laugh at that paper! ... Java on the other hand is cross-platform, and also traditionally runs as an ... - NET programmers continue to struggle with the complexities of a hybrid managed/unmanaged environment. ..... Sorry, I had to laugh at that paper! ... Java on the other hand is cross-platform, and also traditionally runsASSIGNMENT and ESSAY. ... others)Information Technology (Programming/ Languages (Java, C++, VB, .NET, & etc)/Database Design/ Computer Networking/ System Analysis/ Project Management/Project Development/ IT & Society/ and. - NET programmers continue to struggle with the complexiASSIGNMENT and ESSAY. ... others)Information Technology (Programming/ Languages (Java, C++, VB, .NET, & etc)/Database Design/ Computer Networking/ System Analysis/ Project Management/Project Development/ IT & Society/ and. - NET programmers continue to struggle with the complexities of a hybrid managed/unmanaged environment. ..... Sorry, I had to laugh at that paper! ... Java on the other hand is cross-platform, and also traditionally runs as an ... - NET programmers continue to struggle with the complexities of a hybrid managed/unmanaged environment...

Words: 784 - Pages: 4

Free Essay

Object Oriented Programming in Java ‐ Exercises

...OBJECT ORIENTED PROGRAMMING IN JAVA ‐ EXERCISES    CHAPTER 1    1. Write Text‐Based Application using Object‐Oriented Approach to display your name.    // filename: Name.java // Class containing display() method, notice the class doesnt have a main() method public class Name { public void display() { System.out.println("Mohamed Faisal"); } } // filename: DisplayName.java // place in same folder as the Name.java file // Class containing the main() method public class DisplayName { public static void main(String[] args) { Name myname = new Name(); // creating a new object of Name class myname.display(); // executing the display() method in the Name class } }   2. Write a java Applet to display your age.  // filename: DisplayNameApplet.java import java.applet.Applet; // import necessary libraries for an applet import java.awt.Graphics; public class DisplayNameApplet extends Applet { public void paint(Graphics g) { g.drawString("Mohamed Faisal", 50, 25); } } // filename: DisplayNameApplet.htm // place in same folder as the compiled DisplayNameApplet.class file Displaying my Name CHAPTER 2    3.  Write a program that calculates and prints the product of three integers.    // filename: Q1.java import java.util.Scanner; // import Scanner libraries for input public class Q1 { public static void main(String[] args) { Scanner input = new Scanner (System.in); int number1; int number2; int number3; System.out.println("Enter the First Number"); www.oumstudents...

Words: 3130 - Pages: 13

Free Essay

Object Oriented Programming -Java

...Table of Contents TASK A ....................................................................................................................................................... 4 Provide the UML diagrams for the given problem with clear explanations on the design decisions. Derive detailed Use Case diagram, Class diagram & a sequence diagram. Whenever necessary document the relevant assumptions you made. ...................................................................................... 4 TASK B ....................................................................................................................................................... 7 Provide an alternative OO design for the same problem ......................................................................... 7 Object Oriented Known as Methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance. ......................................................................... 7 TASK C ....................................................................................................................................................... 9 There are many system design patterns available in system development. Critically evaluate singleton, factory and abstract factory design patterns and apply the most suitable design pattern for your system development.................................................................................................

Words: 4819 - Pages: 20

Premium Essay

Step by Step Java Eclipse Programming

...They should not be abolished because: * Exams make people better at the subject * content tested in exams are random, so people study everything * since it affects grades, people study harder * there is competition, people study harder * They help the teacher to know what material the students have not mastered and need to study further * They give people important practice in dealing with stress, which can help later on with life's challenges. * The examination system has its own benefits. It's like a self-test to see where we are and how good we fare in something that we do. The purpose of exam has always been a test to let us, human beings, to know our limits and our standards. * Frankly speaking, who can put his/her hand on their heart and say that they would have learned the lessons regarding different subjects themselves if the present examination system were not there and didn't made the students to learn and understand the topics dealing with different subjects to perform at the end of the year. The ANSWER would be No, They wouldn't have. Exams should not be abolished.  Until a better form of demonstrating knowledge comes along, exams must remain in place. In the world of occupations, exams are especially useful.  A given state, county, town, or other regionally-governed area requires certain knowledge for certain occupations.  The most effective way of evaluating an individual's knowledge of a given topic is the use of exams.  These...

Words: 623 - Pages: 3

Premium Essay

Getting Started

...School management system project in java pdf This documentation have all the details about school management system, even in this. Our VisionTo become one of the leading lights in software and webapplication. Generate Bonafide Certificate into PDF Format : 72. AppSolit Project : Managing School Java, Swing, Itext, PDF, JFrame. Boutique Management Software in Java with MySql, JDBC Swing. 2010-повідомлень: 5-авторів: 5Student Management System deals with all kind of student details, academic.pdf Student Management System.pdf Size: 381. Student Management System is software which is helpful for students as well as the school authorities. 2 Database Programming with JDBC and Java by OReillyNeed help with school management system college project java download? Do you specialise in school management system college. School Grade System is a simple project developed in java, jsp servlet for. Tags: exam grading system, exam management system, school grade. Tags: convert pdf files, convert ppt in java, file converter, free java project.School Grade System is a simple project developed in java, jsp servlet for small schools that want to. Knowledge Management System ServletJSP Project. school management system project in java with source code Student attendance management system project in java with source code. At product Instructions for downloadable manuals in PDF. The Relationship Of School Uniforms To Student Attendance.School of informatics. The aim of the project is to develop a...

Words: 610 - Pages: 3

Free Essay

Bankaccount.Java and Program 2.Java

...Question Compile the two test files (BankAccount.java first and then Program2.java second). Execute Program2 with the following inputs: starting balance - $500 (don't enter the dollar sign) monthly interest rate - 0.00125 (this is a 1.5% annual rate) monthly pay - $1000 (don't enter the dollar sign) withdrawal amount - $900 (don't enter the dollar sign) Verify that you earn $0.75 in interest and have an ending balance at the end of the month of $600.75. Then modify the BankAccount class's constructor method to create a BankAccount object which stores a monthly interest when the user inputs an annual interest rate of the format "nnn.nn" (i.e. 1.5). Note that the BankAccount constructor stored a monthly interest rate for the BankAccount object's instance field originally, but the user had to convert the annual rate to a monthly rate (i.e. 1.5 to 0.00125). Then modify the Program2 driver class to prompt the user for an annual interest rate. Recompile both classes and execute the modified Program2 driver class again, this time with following inputs: starting balance - $500 (don't enter the dollar sign) annual interest rate - 1.5 monthly pay - $1000 (don't enter the dollar sign) withdrawal amount - $900 (don't enter the dollar sign) Verify that you still earn $0.75 in interest and still have an ending balance at the end of the month of $600.75 as you did with the original code. Submit only the modified source code...

Words: 1152 - Pages: 5

Free Essay

Programming

...- -[ ] http://blog.renren.com/blog/73603/740437492 » / [ ] 2011-07-18 10:47 | ( : ) http://coolshell.cn/articles/4990.html 6 12 programming An open letter to those who want to start id Mailper Python Web “ Build Your Programming Technical Skills “ ( ) Notes/ActiveX/COM/ADO/ATL/.NET …… Mailper Delphi/Power builder ” Lotus 5 3D TA 561 ” The architecture of w-ai.org –... Some updates and my first Engl... / 10 Unix/Linux Windows 1 Linux Web+ 1 Python/Ruby Web 2 iOS Android Windows Windows Windows Linux+ Windows 9 : csv ( log python csv, python open, python sys) 52 word count (sys, os, path) (python sqlite) print Google (phrase, domain, use reader to follow tech blogs) 2 ( Vim / Emacs / Notepad++ Source Insight ( ctag) Cool IDE) / / 3 Unix/Linux Shell windows man ls/chmod/chown/rm/find/ln/cat/mount/mkdir/tar/gzip … sed/awk/grep/tail/less/more … ps/top/lsof/netstat/kill/tcpdump/iptables/dd… /etc /var/log /proc linux vmware player Ubuntu 1 6 9/6/13 1:36 PM - -[ ] http://blog.renren.com/blog/73603/740437492 /Linux 4 Web Web HTML CSS HTML Firefox + Firebug Javascript HTML DOM Firefox + Firebug Apache PHP PHP PHP chrome Nginx HTML MySQL MySQL SQL http://www.stanford.edu/~ouster/cgi-bin/cs142-fall10/index.php ) javascript HTTP: The Definite Guide browsers) Cookie/Session jQuery 4 3-5 ExtJS + Ajax ( +JSON (proxy, gateway, Javascript box model chrome DOM http://oreilly.com/catalog/9780596527402)...

Words: 807 - Pages: 4