A TECHNICAL REPORT ON THE STUDENT INDUSTRIAL TRAINING(IT 400) UNDERTAKEN AT NEW HORIZONS COMPUTER LEARNING CENTRES No 1,Oba Akran Avenue,Ikeja,Lagos State Written By Tijani Fawaz Akolade EES/15/16/0487 Submitted to THE INDUSTRIAL TRAINING COORDINATOR, DEPARTMENT OF COMPUTER ENGIINEERING, OLABISI ONABANJO UNIVERSITY, AGO-IWOYE,OGUN STATE.IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE AWARD OF B.ENG COMPUTER ENGINEERING OCTOBER 2019. 1|Page Department of ComputerEngineering, Olabisi Onabanjo University, Ago-Iwoye,Ogun State. 16th October 2019. The Industrial Training Coordinator, Department of Computer Engineering, Faculty of Environmental and Engineering Studies, Olabisi Onabanjo University, Ago-Iwoye,Ogun State. CANDIDATE DECLARATION I,TIJANI FAWAZ AKOLADE a student of Computer Engineering in Olabisi Onabanjo University with the matric number EES/15/16/0487,hereby declare that the work presented inthis dissentation is the report of my six months Industrial training exercise undertaken at New Horizons Computer Training Centre,Ikeja,Lagos,as a follow up to satisfy one of the requirements of Nigerian Universities Commission(NUC) for science and engineering students in Tertiary Institutions. Please find attached to this letter,a copy of my report. Thanks for your co-operation. Yours faithfully, TIJANI Fawaz Akolade, Computer Engineering, Olabisi Onabanjo University, Ago-Iwoye. +234(0)9057750690 Tijanifawaz35@gmail.com 2|Page ACKNOWLEDGEMENT The completion of this training work could have been possible with continued efforts and dedicated efforts and guidance of large number of faculty and staff members of the institute. I acknowledge my gratitude to all of them. The acknowkedgement however will be incomplete without specific mention as follows. I wish to acknowledge my deep gratitude to Mr Agboola Oladipo, supervisors at New Horizons Computer Training Centre for his cooperation and guidance. I am also thankful to Mr Yusuf that provided staunch support throughout the training and helped me to complete the training successfully. Furthermore, I would also acknowlegde with so much appreciation to crucial role of our HOD Prof Folorunsho for his encouragement and providing all the facilities in the department. Finally, I would like to say that I am in debted to my parents Mr and Mrs Tijani for everything they have done for me. All of this would be impossible without their constant support and I thank God for being kind and driving me through the journey. 3|Page ABSTRACT The industrial report presents the experience gained during my duration of six(6) months of industrial training undertaken at the NEW HORIZONS COMPUTER LEARNING CENTERS, IKEJA, LAGOS STATE. My training was based on hardware and software repairs,SQL and Java Programmng language. I acquired practical knowledge on some basic parts of hardware, software and JAVA programming language. This report discusses the technical skills gained during the training period and justifying the relevance of the scheme in equipping students with needed technical competence to thrive in the real world. 4|Page TABLE OF CONTENTS Letter of Transmittal……………………………………………………………………….…iii Acknowledgement…………………………………………………………………………….iv Abstract ………………………………………………………………………………………v Table Of Content………………………………………………………………………………v List of Tables………………………………………………………………………………….x Company Profile ........................................................................................................................ 1 CHAPTER ONE 1.1 1.2 1.3 INTRODUCTION,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,........ History and Background of SIWES Programme………………………………………8 Aims and Objectives of SIWES……………………………………………………….9 Brief History and Profile of the organisation………………………………………...10 CHAPTER TWO INTRODUCTION TO COMPUTER…………................................... 2.0 Introduction to computer....................................................................................................11 2.1 Characteristics of Computer .............................................................................................. 12 2.2 Components of Computer………………………………………………………………..12 2.3 Connection Interface........................................................................................................15 2.3.1 Physical Connection……………………………………………………………15 2.3.2 Wireless Connection……………….…………………………………………..20 CHAPTER THREE NETWORKING ............................................................................. 21 3.0 Introduction to computer networking……………………………...………...............21 3.1 Types of networking................................................................................................... 22 3.2 Computer Network Cables..........................................................................................22 3.3 Network Protocol....................................................................................................... 25 3.3.1 Internet Protocol Version 4(IPV4)……………………………………………..27 3.3.1 Classes…………………………………………………….……………………28 3.3.2 Subnet masking………………………………………………………………...28 CHAPTER FOUR SQL OVERVIEW………………………………….……………….30 4.0 SQL OVERVIEW…………………………………………...………………………….30 5|Page 4.1 SQL Process……………………………………………………………………………..30 4.2 SQL Commands……………………………………………………………………...…31 4.2.1 Data Manipulation Language……………………………………………..........31 4.2.2 Data control Language………………………………………………………....31 4.3.3 Data Query Language……………………………………………………..........32 4.3 SQL RDBMS Concept………………………………………………………………….32 4.4 Data Normalisation……………………………………………………………………..33 4.4.1 Forms…………………………………………………………………...………34 4.5.2 Rules……………………………………………………………………...…….36 4.5 SQL Syntax ……………………………………………………………………………..36 4.6 SQL Data types…………………………………………………………………….........37 4.8 SQL Operators………………………………………………………………………….38 CHAPTER FIVE JAVA 5.0 Introduction To Java.......................................................................................................40 5.1 Java Virtual machine & its architecture........................................................................41 5.2 Classes...............................................................................................................................42 5.3 Variables in Java..............................................................................................................43 5.4 Decision Making in Java ……………………………………………………………….45 5.4.1 IF Statement……………………………………………………………………45 5.4.2 IF/Else Statement…………………………………………………………........46 5.5 Concept Of Array In Java……………………………………………………………...46 5.5.1 Array Declaration………………………………………………………………46 5.5.2 Initialization of Array…………………………………………………………..47 5.5.3 How to loop through an array…………………………………………….........47 5.6 Object….……………………………………………………………………………...…49 5.6.1 Declaring object………………………………………………………………..49 5.6.2 Dot operator……………………………………………………………………50 5.6.3 References of an object……………………………………………...…..…….50 6|Page 5.7 Method..............................................................................................................................62 5.8 Constructors……………….…………………………………………………………....64 5.9.1 Definition…………………………………………………………………..…..64 5.9.2 Creating a constructor……………………………………………………….…64 CHAPTER SIX RECOMMENDATION & CONCLUSION ………...............53 6.1 Recommendation………………………………………………………………..53 6.2 Conclusion…………………………………………………………………...….53 7|Page 1.0 HISTORICAL BACKGROUND OF SIWES SIWES was established by ITF in 1973 to solve the problem of lack of adequate practical skills preparatory for employment in industries by Nigerian graduates of tertiary institutions. The Scheme exposes students to industry based skills necessary for a smooth transition from the classroom to the world of work. It affords students of tertiary institutions the opportunity of being familiarized and exposed to the needed experience in handling machinery and equipment which are usually not available in the educational institutions. Participation in Industrial Training is a well-known educational strategy. Classroom studies are integrated with learning through hands-on work experiences in a field related to the student’s academic major and career goals. Successful internships foster an experiential learning process that not only promotes career preparation but provides opportunities for learners to develop skills necessary to become leaders in their chosen professions. One of the primary goals of the SIWES is to help students integrate leadership Development into the experiential learning process. Students are expected to learn and develop basic nonprofit leadership skills through a mentoring relationship with innovative non-profit leaders. By integrating leadership development activities into the Industrial Training experience, we hope to encourage students to actively engage in non-profit management as a professional career objective. However, the effectiveness of the SIWES experience will have varying outcomes based upon the individual student, the work assignment, and the supervisor/mentor requirements. It is vital that each internship position description includes specific, written learning objectives to ensure leadership skill development is incorporated. Participation in SIWES has become a necessary pre-condition for the award of Diploma and Degree certificates in specific disciplines in most institutions of higher learning in the country, in accordance with the education policy of government. 1.1 Aims and Objectives of SIWES 1. SIWES will provide students the opportunity to test their interest in a particular career before permanent commitments are made. 2. SIWES students will develop skills in the application of theory to practical work situations. 3. SIWES will provide students the opportunity to test their aptitude for a particular career before permanent commitments are made. 8|Page 4. SIWES students will develop skills and techniques directly applicable to their careers. 5. SIWES will aid students in adjusting from college to full-time employment. 6. SIWES will provide students the opportunity to develop attitudes conducive to effective interpersonal relationships. 7. SIWES will increase a student's sense of responsibility. 8. SIWES students will be prepared to enter into full-time employment in their area of specialization upon graduation. 9. SIWES students will acquire good work habits. 10. SIWES students will develop employment records/references that will enhance employment opportunities. 11. SIWES will provide students the opportunity to understand informal organizational interrelationships. 12. SIWES will reduce student dropouts. 13. SIWES Students will be able to outline at least five specific goals with several staff members by comparing performance with job duties and develop a draft plan with staff to accomplish performance needs, supervision plan and rewards. 14. SIWES Students will be able to develop a draft agency or project budget and will be able to identify methods of obtaining revenue to support the budget. 15. SIWES Students will be able to provide tools to use in prioritizing tasks of an assigned project and create with staff a tentative schedule for completion based on these tasks. 16. SIWES Students will be able to develop a model policy that gives current front-line leaders the permission and expectation to work with other staff on conflict resolution and explain how this works to current front line leaders. 17. SIWES Students will be able to describe different skills leaders can use to Foster commitment and collaboration with both internal and external constituents. The six months Students Industrial Work Experience Scheme (SIWES) which is a requirement for the completion of my course of study as a Computer Engineer, was undertaken at New Horizons Computer Learning Centre. The Organization has a lot of experience in IT field and mostly in Computer Engineering courses like Programming, Networking and a lot more. This Organization presents to us a quality and efficient training, basically as a Computer Engineering Students. 9|Page 1.2 Brief History and Profile of the Organisation Since 1982, New Horizons Computer Learning Centers has grown to become the largest independent IT training company worldwide. We offer more courses, at more times and in more locations than any other computer and business training company. Businesses and individuals can choose from hundreds of course offerings, delivered by experts, and offered in hundreds of convenient locations around the world. For many small, medium and large organizations, New Horizons is the single source for all their IT training needs. New Horizons Nigeria was granted the license as a franchisee of New Horizons world-wide to operate in Nigeria in May 2004. The firms’ vision is to be the foremost provider of IT training in Nigeria; in order to achieve this vision, we believe we need the right values to propel the organization to the forefront of the IT training industry in Nigeria; our values therein are Integrity, Innovation & Culture of Responsibility. The IT skills level in Nigeria is still in her formative stages and years behind other countries in America, Europe and Asia. IT has also proven to be the greatest creator/driver of wealth in these countries and Nigeria has been unable to partake in this because of our dearth of skills in this area. The founders of New Horizons Nigeria saw the deepening of the IT knowledge divide between the developed nations and the developing ones and in order to bridge this divide, they decided to form a strategic alliance with the most reputable IT training organization in the world – New Horizons World-wide to provide world class IT training to the people of Nigeria. New Horizons Nigeria strongly believes that by doing this, she will contribute immensely to the socio-economic development of Nigeria and is currently the largest IT training company in Nigeria. 10 | P a g e CHAPTER TWO 2.0 Introduction to computer A computer is a device that accepts information (in the form of digitalized data) and manipulates it for some result based on a program, software, or sequence of instructions on how the data is to be processed. Complex computers include the means for storing data (including the program, which is also a form of data) for some necessary duration. A program may be invariable and built into the computer hardware (and called logic circuitry as it is on microprocessors) or different programs may be provided to the computer (loaded into its storage and then started by an administrator or user). Today's computers have both kinds of programming. Major types of computers • Analog computer - represents data by measurable quantities • Desktop computer - a personal computer that fits on a desk and is often used for business or gaming • Digital computer - operates with numbers expressed as digits • Hybrid computer - combines features of both analog and digital computers • Laptop (notebook) - an easily transported computer that is smaller than a briefcase • Mainframe (big iron) computer - a centralized computer used for large scale computing • Microcomputer - generally referred to as a PC (personal computer). Uses a single integrated semiconductor chip microprocessor. • Minicomputer - an antiquated term for a computer that is smaller than a mainframe and larger than a microcomputer • Netbook - a smaller and less powerful version of a laptop • Personal computer (PC) - a digital computer designed to be used by one person at a time • Smartphone - a cellular telephone designed with an integrated computer • Supercomputer - a high performing computer that operates at extremely high speeds • Tablet computer (tablet PC) - a wireless personal computer with a touch screen • Workstation - equipment designed for a single user to complete a specialized technical/scientific task 11 | P a g e 2.1 Characteristics of Computer Speed, accuracy, diligence, storage capability and versatility are some of the key characteristics of a computer. Brief overviews of these characteristics are: • Speed: The computer can process data very fast, at the rate of millions of instructions per second. Some calculations that would have taken hours and days to complete otherwise, can be completed in a few seconds using the computer. For example, calculation and generation of salary slips of thousands of employees of an organization, weather forecasting that requires analysis of a large amount of data related to temperature, pressure and humidity of various places, etc. • Accuracy: Computer provides a high degree of accuracy. For example, the computer can accurately give the result of division of any two numbers up to 10 decimal places. • Diligence: When used for a longer period of time, the computer does not get tired or fatigued. It can perform long and complex calculations with the same speed and accuracy from the start till the end. • Storage Capability: Large volumes of data and information can be stored in the computer and also retrieved whenever required. A limited amount of data can be stored, temporarily, in the primary memory. Secondary storage devices like floppy disk and compact disk can store a large amount of data permanently. • Versatility: Computer is versatile in nature. It can perform different types of tasks with the same ease. At one moment you can use the computer to prepare a letter document and in the next moment you may play music or print a document. Computers have several limitations too. Computer can only perform tasks that it has been programmed to do. Computer cannot do any work without instructions from the user. It executes instructions as specified by the user and does not take its own decisions. 2.2 COMPONENTS OF COMPUTER Motherboard The motherboard is a circuit on which all the electronic components are connected. This include both internal parts of the system unit like processor, display card of the monitor, sound card, memory etc. and the connector of external parts like mouse keyboard, hard disk, floppy disk etc. the ports and slots which connect these components also exist in the motherboard. The circuits in the motherboard help in data transfer among the components. Bios, RAM slots and chipset are also mounted on the motherboard. 12 | P a g e MOTHERBOARD COMPONENTS: MOTHERBOARD 13 | P a g e PROCESSOR One of the most important parts of computer called as heart of computer. The brain of a computer is it processor. The processor in a modern computer is an Integrated Circuit (IC) chip. PROCESSOR A chip of millions of transistors and capacitors which can process the data obtained thorough input devices and transfer the result to the output units. Processors from different companies are available today. Intel –PentiumIV, Xenon, Celeron AMD Athlon, Cyrix M3 etc. are popular. Arithmetic and Logic Unit & Control Unit (ALU& CPU) The two main parts of a processor are Arithmeticand Logic Unit(ALU) and Control Unit (CU). The functions of the ALU is to do the processing and mathematical calculations of the information obtained through input devices. The control unit sorts this information and sends it to the different parts of the computer like the manager of an office. The control unit organizes and coordinates various function of a computer. The orderly and fast functioning of a computer indicates the efficiency of the control unit. COOLING FAN A fan is often fixed on the processor to remove the heat generated by continuous activity. This is known as the processor fan. PROCESSOR SOCKET The processor socket is used to fix the processor in a computer. Different kind of motherboard are available today, depending upon the size and the number of pins of a processor. 14 | P a g e KEYBOARD The keyboard of a computer looks quite similar to the keyboard of a typical typewriter. The keyboard may have 84, 101, or 104 keys. The keys on the computer keyboard are arranged in the same order as on the keyboard of an ordinary typewriter. There a few additional keys on the computer keyboard. The keyboard contains alphanumeric keys to enter the string and the numbers. For the frequent calculation and the numerical entries, numeric pad is provided. There are also function keys. Use of them is to perform specific function with a single key stroke. 2.3 CONNECTION INTERFACE The connection interfaces is anything that interference while there is the connection established the computer. The interferences can play some really vital role especially when it comes to the connectivity. These connections cannot only be for the intangible factors, but there can be some physical interferences as well through which the physical devices interact with the computer and create some connection with them. Many of the unstable and the slow Wi-Fi connection problem arise when there is the weak interference. Following are the connection interferences and the purposes that they serve; 2.3.1 Physical Connections: There are the connections which are made externally and the data can be transferred without opening up the PC and the mediums used for the data transfer have some speeds as well. Some of those physical connections are as below; USB 1.1 vs. 2.0 vs. 3.0 Speed and the Distant Characteristics: The USB is the most common way to get the devices commented to the computer. The oldest version of the USB is called the standard 1.1. Is it pretty old and was the first ever version introduced by the USB. The low speed of the USB is around 1.5 m per seconds. The cable through which I t can run at this rate is 3 meters. The full speed that this version has is 12 megabits per seconds and it requires the maximum of 5 meters cable at which this speed can really work on. The version 2.0 is the second version and is considered as the modern and latest version. Most of the people are using this version currently. It also has high speed. At five meter long cable, the slow speed that this USB has got is 480 megabits per second. SO hence it has some really big edge over the previous USB version of 1.1. The latest version that is coming out in the market is of the USB 3.0. At some places, this version can be seen. 15 | P a g e Users are calling it the super Speed USB since the amount of data that it can handle is 4.8 GB per second. It is a huge increase over the 2.0 USB which entertains the data at sped of only 480 megabits. But, the distance which allowed the transfer of data at such amazingly huge rate is pretty small. The maximum distance which can bear this speed is 3 meters. Connector type micro, mini, A and B: Normally USB has only two types which are A and B. They are mostly used in all USB. The type A is normally flat and has the rectangular surface. The interface has the connection by the friction which makes it become toe ay for the user to connect or disconnect the USB with the port. The type B USB connectors are made doe the USB peripheral device. It is square type in the shape and it has somehow, some bevelled corners which are located at some top ends of the connectors. Just like type A, there is some friction there which helps the user use this connector with ease. The micro and Mini USB are of many types like there is Mini USB 5b pin, 4 pin and Fuji while the micro USB is of type A, B and AB. They all have some different shapes and hence are recognized majorly by their shapes. The micro USB connectors are normally smaller than normal connectors and the mini USB types are smaller than micro USB connectors. Both of these are used majorly in the devices like mobile phones, PDAs and the digital cameras etc. Firewire 800 vs. Firewire400 speed and distance characteristics: Here is another interface connection type which is pretty common among all the connections. It is called the Firewire. Sometimes, it is also called as the IEE 1394. Apple has given it the name of Firewire. Some other manufacturers give it the name of Lynx or the iLink. This amazing interface gives the user authority to get almost 63 devices connected to each other. Hence these devices can get connected to the computer with the help of only one interface that is the Firewire. One would find the two types of the Firewire. The first one is called as the Firewire 400. In the half duplex, it can run at 100, 200 and the 400 Megabits. The distance that one should imagine with the Firewire is mostly 4 and the half meters which make up 15 meters long. The maximum reach can be 72 meters. Each Firewire device is kind of repeater. One can hence, have the total distance of a 15 feet cable and the Firewire device, and the other Firewire device again would come at the distance of 15 meters. Hence it can make up its way all to the 63 various devices. The total distance that would be there is the 73 meters. One might not be able to set up the 4 and the half meter distance among each drive 16 | P a g e but as long as the distance doesn't exceed the 72 meters, then one can use the Firewire 400. The newer version of the Firewire is the Firewire 800. This update has allowed the users to have some great speed. The point to be noticed is that this Firewire 800 has the speed of 800 megabits per second. It can go with the full duplex. So it indicates that there would be the 800 megabits at one direction while the other direction would also have the same 800 megabits. There are some various other types of the connections as well which can be used for the Firewire 800. One of them is the optional connection and it allows the user to go to the 100 meters as well. The copper connection would allow this distance but still, one would have to maintain the distance of 4 and half meters and the maximum of 72 meters distance of the wire. SATA 1 vs. SATA 2 vs. SATA 3, IDE speeds and e SATA: The SATA is the most common standards which can be found on the computers used in the today's life. SATA 1 is the first ever version of the SATA which actually allowed the transfer of 1.5 gigabits in a second. The maximum cable size that can be used by the SATA among the motherboard and the device is only a half meter. The SATA 2, as the name indicates, is the upgraded version of the SATA1. It contained some revisions which allowed it to transfer the data at the rate of around 3 giga bits per seconds and the length of the cable used for this purpose can be one meter. Hence the speed was changed but the length wasn't changed at all. There then, was introduced a third version of SATA as well which is called the SATA 3. This version can now carry a huge amount of data transfer that is 6giga bits. The size again, hasn't been changed and it adjusts the speed which kept being doubled. But one can use the eSATA as well. It stands for the external SATA. These devices can be used outside the computer. The speed of this SATA would normally be matching the speed of other SATA devices but since it is operating outside the computer, so one can increase the distance of the cable and hence it can become a little longer when the drive if moved from the computer. The maximum distance it can be moved towards is the 2 meters. Other Connection Types: There are some other connection types as well, which help the computer get connected to the rest of its parts both internally and externally. These connections types are as follows; 17 | P a g e Serial: The serial cable is accountable of transferring the data between the two devices with the help of some serial communication protocol. The shape and the form of the connectors can entirely depend on the particular serial port that has been sed. VGA: Video graphic accelerator connectors are normally the ones we see at the back of the computer. They are normally available in multi-colour and look so bright to the eyes. So hence one can recognize theme easily. They can carry both the audio and the video signals through the cables. Also, there can be used the shielded cables which help a lot reducing some noise and the RFI, hence placing some high quality data transfer through the wires. HDMI: The HDMI cables are of five types and the type can be chosen based on the work it has to perform. The standard bale is the one which is designed to take care of most of the home appliance and the computer power as well. It can give some HD resolutions since the data can travel in some really neat way. The second is the HDMI with the Ethernet. Ethernet is normally used for connecting the LAN card to the modem when the Wi-Fi isn't available. Hence the good speed of data can be transferred which results in high quality internet. Betides regular Ethernet cable, there is the high speed HDMI cable as well which is specially designed for high speed networking's. Audio: The audio cable is very normal and is sued frequently by everyone. They are like the cable we plug in the computers and that wire is connected to the headset. RJ-45: RJ 45 is very standardized cable and mostly it is seen in the edged of the Ethernet cable. It is in somehow, a square shape. DVI: The digital visual interface is the name of this connector. It has two types which can support the analogue and digital media transfer. 18 | P a g e RJ-11: RJ 11 is a bit different from the RJ 45. It is smaller and is used in the phone connectors. It contains around 4-6 wires in it. Analogue vs. Digital transmission: VGA vs. HDMI: As we know there are two types of connections which can be for analogue and the digital signals. That's the difference between these two connector's types. The VGA allows the analogue transmission while HDMI allowed the digital transmission. Overall, the HDMI wins over the VGA since it has the digital data transmission which is more reliable and better. 2.3.2 Wireless Devices Connections: The wireless technologies cannot be easily determined in terms of the distances and the lengths. The reason is that there are many variables involved here which can resist the 19 | P a g e measurement. But the result can be generated which can be really close to the actual measurement. Some of these wireless technologies are as follows; Bluetooth: The distances which are covered by the wireless derives are normally too short. They are measured in some feet and meters. The blue tooth is the wireless device that can provide some longer distance since the distance is extended a bit. There is more flexibility in the devices which can be found. For example, the blue tooth 2.0 is also known as the EDR. The speed that this gadget has is 3 megabits per second. The distance which can be travelled by it is 10 meters. Also, 30 feet's off from the services for the class second devices. The class three bluetooth mediums have the distance of around 1 meter which is just three feet. RF: RF stands for the Radio frequency. It has now become the same as the high frequency signals and the wireless. It is basically a wireless electromagnetic energy which is mainly used for the communication. The frequency of it is ranged between 3 to 300 Hz. The frequency means the rate of the oscillation of the waves, or the speed at which the signals can get transferred. In computer industry it has a major role since many of the devices has it as the wireless network and it plays some important role in the LAN (local area network). IR: IR stands for the infrared. This communication technology is basically used to connecting the devices which are located at some short ranges. This communication has some serious limitations. One of them is that it asks for some short ling of the sight. Its transmission range is pretty narrow and it doesn't have the ability to penetrate through the walls. The services of the IR technologies are pretty cheap and they are used only as the short term range communications made. The data transmission which is transferred between the IrDA devices is normally unencrypted. Also, the limitations cause the interception of this communication become more difficult, It I a common practice that the IrDA devices communications are normally exchanged on the one to one basis. The fastest data rate that is has is 14 MB. It can work only up to the 10 meters but the technologies and the appliances it is used it, are okay with this distance and speed. Normally the remote controls that one uses at the house, work on this technology as well. One PC can contain so many connections and these all connections can get connected to the motherboard in various ways. But they might become confusing for the user since the type and the connections can resemble sometimes so it's better for a user to know what kind of connection is required at a specific connector so that he can make the appropriate arrangements without any problem. 20 | P a g e CHAPTER THREE COMPUTER NETWORKING 3.0 INTRODUCTION TO COMPUTER NETWORK Networking, also known as computer networking, is the practice of transporting and exchanging data between nodes over a shared medium in an information system. Networking comprises not only the design, construction and use of a network, but also the management, maintenance and operation of the network infrastructure, software and policies. Computer networking enables devices and endpoints to be connected to each other on a local area network (LAN) or to a larger network, such as the internet or a private wide area network (WAN). This is an essential function for service providers, businesses and consumers worldwide to share resources, use or offer services, and communicate. Networking facilitates everything from telephone calls to text messaging to streaming video to the internet of things (IoT). The level of skill required to operate a network directly correlates to the complexity of a given network. For example, a large enterprise may have thousands of nodes and rigorous security requirements, such as end-to-end encryption, requiring specialized network administrators to oversee the network. At the other end of the spectrum, a layperson may set up and perform basic troubleshooting for a home Wi-Fi network with a short instruction manual. Both examples constitute computer networking. 3.1 Types of networking There are two primary types of computer networking: wired networking and wireless networking. Wired networking requires the use of a physical medium for transport between nodes. Copper-based Ethernet cabling, popular due to its low cost and durability, is commonly used for digital communications in businesses and homes. Alternatively, optical fiber is used to transport data over greater distances and at faster speeds, but it has several tradeoffs, including higher costs and more fragile components. Wireless networking uses radio waves to transport data over the air, enabling devices to be connected to a network without any cabling. Wireless LANs are the most well-known and widely deployed form of wireless networking. Alternatives include microwave, satellite, cellular and Bluetooth, among others. As a general rule, wired networking offers greater speed, reliability and security compared to wireless networks; wireless networking tends to provide more flexibility, mobility and scalability. 21 | P a g e It should be noted that these types of networking concern the physical layer of the network. Networking can also be classified according to how it's built and designed, encompassing approaches that include software-defined networking (SDN) or overlay networks. Networking can also be categorized by environment and scale, such as LAN, campus, WAN, data center networks or storage area networks. Components of networking Computer networking requires the use of physical network infrastructure -- including switches, routers and wireless access points -- and the underlying firmware that operates such equipment. Other components include the software necessary to monitor, manage and secure the network. Additionally, networks rely on the use of standard protocols to uniformly perform discrete functions or communicate different types of data, regardless of the underlying hardware. For example, voice over IP (VoIP) can transport IP telephony traffic to any endpoint that supports the protocol. HTTP provides a common way for browsers to display webpages. The internet protocol suite, also known as TCP/IP, is a family of protocols responsible for transporting data and services over an IP-based network. 3.2 Computer Network Cables ETHERNET There are basically two types of computer network cables. There are straight through cables, and crossover cables. They look very similar, but it is possible to tell them apart. This article will help you do just that. There are also different categories of Ethernet cables such as Cat 5, Cat 5e and Cat 6. The list below, summarizes each of the different types of ethernet cabling. Cat 3 – typically used for voice cabling and the slower 10Mb Ethernet. These were a popular cabling format in the 1990s. Read more on the Cat 3 Cable here. Cat 5 – used for the 10/100Mb Ethernet networks and also used for voice cabling, token ring and ATM. Cat 5 cables were superceded by the superior Cat 5e cabling. Read More. Cat 5E – an improved version of Cat5 cabling that prevents cross-talk and is rated at a much higher 350Mhz. Cat5e cables are also used for the 10/100Mb networks and the 1000Mb (or Gigabit Ethernet) networks. Read more on Cat 5e cables here. Cat 6 – used for the 10/100/1000Mb networks. Similar to the Cat5e cables but with larger gauge wires. People incorrectly assume that getting Cat 6 cables will automatically increase your network speeds to Gigabit (1000Mb) speeds. However, this is only possible if everything in your network (cards, switch and cables are all Gigabit certified). Read more on Cat 6 cables here. Cat 7 – also known as class F, this fully-shielded cable is relatively new and isn’t used as much at the moment. Cat 7 cables support frequencies of up to 600Mhz. Read more on Cat 7 cables. 22 | P a g e However not only is it important to be aware of the different categories of network cabling, it is also beneficial to be aware of the “ends” and “plugs” at each end of the cable. There are basically two types of Ethernet cables. There are the normal regular straight through cables and the other type is crossover cables. Straight Through Cables When you buy “regular” computer network cables, you are really just buying a straight through Ethernet cable. This means that both ends of the cables will be identical. The colours of the smaller cables inside the ethernet cable, will be in the same order, from left to right. This type of cable is used for connecting a PC to a hub/switch or for connecting a router to a switch. The hub/switch performs the crossover for you, that is why you need a crossover cable, for when you connect a PC directly with another PC. Crossover Cables A crossover Ethernet cable have a different look on either side of the cable. The purpose of the crossover cable, is to connect one device directly to another device, without a switch or hub being present. So if you were connecting one PC directly with another PC, you would then use a crossover network cable. The image below, shows the differences between a crossover cable and a straight through computer network cable. 23 | P a g e Coaxial Cables Invented in the 1880s, "coax" was best known as the kind of cable that connected television sets to home antennas. Coaxial cable is also a standard for 10 Mbps Ethernet cables. When 10 Mbps Ethernet was most popular, during the 1980s and early 1990s, networks typically utilized one of two kinds of coax cable — thinnet (10BASE2 standard) or thicknet (10BASE5). These cables consist of an inner copper wire of varying thickness surrounded by insulation and another shielding. Their stiffness caused network administrators difficulty in installing and maintaining thinnet and thicknet. Fiber Optics Instead of insulated metal wires transmitting electrical signals, fiber optic network cables work using strands of glass and pulses of light. These network cables are bendable despite being made of glass. They have proven especially useful in wide area network (WAN) installations where long distance underground or outdoor cable runs are required and also in office buildings where a high volume of communication traffic is common. Two primary types of fiber optic cable industry standards are defined — single-mode (100BaseBX standard) and multimode (100BaseSX standard). Long-distance telecommunications networks more commonly use single-mode for its relatively higher bandwidth capacity, while local networks typically use multimode instead due to its lower cost. 24 | P a g e USB Cables Most Universal Serial Bus (USB) cables connect a computer with a peripheral device (keyboard or mouse) rather than to another computer. However, special network adapters (sometimes called dongles) also allow connecting an Ethernet cable to a USB port indirectly. USB cables feature twisted pair wiring. 3.3 Network Protocols Network protocols are sets of established rules that dictate how to format, transmit and receive data so computer network devices -- from servers and routers to endpoints -- can communicate regardless of the differences in their underlying infrastructures, designs or standards. To successfully send and receive information, devices on both sides of a communication exchange must accept and follow protocol conventions. Support for network protocols can be built into software, hardware or both. Standardized network protocols provide a common language for network devices. Without them, computers wouldn't know how to engage with each other. As a result, except for specialty networks built around a specific architecture, few networks would be able to function, and the internet as we know it wouldn't exist. Virtually all network end users rely on network protocols for connectivity. How network protocols work Network protocols break larger processes into discrete, narrowly defined functions and tasks across every level of the network. In the standard model, known as the Open Systems Interconnection (OSI) model, one or more network protocols govern activities at each layer in the telecommunication exchange. A set of cooperating network protocols is called a protocol suite. The TCP/IP suite includes numerous protocols across layers -- such as the data, network, transport and application layers -- working together to enable internet connectivity. These include: Transmission Control Protocol (TCP), which uses a set of rules to exchange messages with other internet points at the information packet level; User Datagram Protocol (UDP), which acts as an alternative communication protocol to TCP and is used to establish low-latency and loss-tolerating connections between applications and the Internet. Internet Protocol (IP), which uses a set of rules to send and receive messages at the Internet address level; and additional network protocols that include the Hypertext Transfer Protocol (HTTP) and File Transfer Protocol (FTP), each of which has defined sets of rules to exchange and display information. Every packet transmitted and received over a network contains binary data. Most protocols will add a header at the beginning of each packed in order to store information about the 25 | P a g e sender and the message's intended destination. Some protocols may also include a footer at the end with additional information. Network protocols process these headers and footers as part of the data moving among devices in order to identify messages of their own kind. Network protocols are often set forth in an industry standard -- developed, defined and published by groups such as: the International Telecommunication Union the Institute of Electrical and Electronics Engineers the Internet Engineering Task Force the International Organization for Standardization the World Wide Web Consortium. Major types of network protocols Generally speaking, networks have three types of protocols -- communication, such as Ethernet; management, such as the Simple Mail Transfer Protocol (SMTP); and security, such as Secure Shell (SSH). Falling into these three broad categories are thousands of network protocols that uniformly handle an extensive variety of defined tasks, including authentication, automation, correction, compression, error handling, file retrieval, file transfer, link aggregation, routing, semantics, synchronization and syntax. Implementing network protocols In order for network protocols to work, they must be coded within software, either a part of the computer's operating system (OS) or as an application, or implemented within the computer's hardware. Most modern operating systems possess built-in software services that are prepared to implement some network protocols. Other applications, such as web browsers, are designed with software libraries that support whatever protocols are necessary for the application to function. Furthermore, TCP/IP and routing protocol support is implemented in direct hardware for enhanced performance. Whenever a new protocol is implemented, it is added to the protocol suite. The organization of protocol suites is considered to be monolithic since all protocols are stored in the same address and build on top of one another. Vulnerabilities of network protocols One major vulnerability found in network protocols is that they are not designed for security. Their lack of protection can sometimes allow malicious attacks, such as eavesdropping and cache poisoning, to affect the system. The most common attack on network protocols is the advertisement of false routes, causing traffic to go through compromised hosts instead of the appropriate ones. Network protocol analyzers have been designed and installed in response to these vulnerabilities. Network protocol analyzers protect systems against malicious activity by supplementing firewalls, anti-virus programs and anti-spyware software. 26 | P a g e Uses of network protocols Network protocols are what make the modern Internet possible since they allow computers to communicate across networks without users having to see or know what background operations are occurring. Some specific examples of network protocols and their uses are: Post Office Protocol 3 (POP3), which is the most recent version of a standard protocol that is used for receiving incoming e-mails. Simple main transport Protocol, which is used to send and distribute outgoing e-mails. File Transfer Protocol (FTP), which is used to transfer files from one machine to another. Telnet, which is a collection of rules used to connect one system to another via a remote login. In this protocol, the system that send the request for connection is the local computer and the system that accepts the connection is the remote computer. Some other network protocol examples include: Address Resolution Protocol Blocks Extensible Exchange Protocol Border Gateway Protocol Binary Synchronous Communications Canonical Text Services Domain name system Dynamic Host Configuration Protocol Enhanced Interior Gateway Routing Protocol HTTP over SSL Human interface device Internet Control Message Protocol Internet Message Access Protocol Gopher Media access control Network News Transfer Protocol Open Shortest Path First Post Office Protocol Secure Sockets Layer Simple Mail Transfer Protocol Telnet Terminal Network Thread Transmission Control Protocol Transport Layer Security Universal Description, Discovery and Integration User Datagram ProtocoL 3.3.1 Internet Protocol Version 4 (IPv4) Internet Protocol Version 4 (IPv4) is the fourth revision of the Internet Protocol and a widely used protocol in data communication over different kinds of networks. IPv4 is a connectionless protocol used in packet-switched layer networks, such as Ethernet. It provides the logical connection between network devices by providing identification for each device. There are many ways to configure IPv4 with all kinds of devices – including manual and automatic configurations – depending on the network type. 27 | P a g e IPv4 is based on the best-effort model. This model guarantees neither delivery nor avoidance of duplicate delivery; these aspects are handled by the upper layer transport. IPv4 Classful Addressing 3.3.2 Classes To provide flexibility in the number of addresses distributed to networks of different sizes, 4octet (32-bit) IP addresses were originally divided into three different categories or classes: class A, class B, and class C. Each address class specifies a different number of bits for its network prefix and host number: Class A addresses use only the first byte (octet) to specify the network prefix, leaving 3 bytes to define individual host numbers. Class B addresses use the first 2 bytes to specify the network prefix, leaving 2 bytes to define host addresses. Class C addresses use the first 3 bytes to specify the network prefix, leaving only the last byte to identify hosts. In binary format, with an x representing each bit in the host number, the three address classes can be represented as follows: 00000000 xxxxxxxx xxxxxxxx xxxxxxxx (Class A) 00000000 00000000 xxxxxxxx xxxxxxxx (Class B) 00000000 00000000 00000000 xxxxxxxx (Class C) Because each bit (x) in a host number can have a 0 or 1 value, each represents a power of 2. For example, if only 3 bits are available for specifying the host number, only the following host numbers are possible: 111 110 101 100 011 010 001 000 In each IP address class, the number of host-number bits raised to the power of 2 indicates how many host numbers can be created for a particular network prefix. Class A addresses have 224 (or 16,777,216) possible host numbers, class B addresses have 216 (or 65,536) host numbers, and class C addresses have 28 (or 256) possible host numbers. 28 | P a g e IPv4 Dotted Decimal Notation The 32-bit IPv4 addresses are most often expressed in dotted decimal notation, in which each octet (or byte) is treated as a separate number. Within an octet, the rightmost bit represents 20 (or 1), increasing to the left until the first bit in the octet is 27 (or 128). Following are IP addresses in binary format and their dotted decimal equivalents: 11010000 01100010 11000000 10101010 = 208.98.192.170 01110110 00001111 11110000 01010101 = 118.15.240.85 00110011 11001100 00111100 00111011 = 51.204.60.59 29 | P a g e CHAPTER FOUR 4.1 SQL OVERVIEW SQL tutorial gives unique learning on Structured Query Language and it helps to make practice on SQL commands which provides immediate results. SQL is a language of database, it includes database creation, deletion, fetching rows and modifying rows etc. SQL is an ANSI (American National Standards Institute) standard, but there are many different versions of the SQL language. What is SQL? SQL is Structured Query Language, which is a computer language for storing, manipulating and retrieving data stored in relational database. SQL is the standard language for Relation Database System. All relational database management systems like MySQL, MS Access, Oracle, Sybase, Informix, postgres and SQL Server use SQL as standard database language. Also, they are using different dialects, such as: -SQL, Oracle using PL/SQL, Why SQL? e and manipulate that data. -compilers. 4.1 SQL Process: When you are executing an SQL command for any RDBMS, the system determines the best way to carry out your request and SQL engine figures out how to interpret the task. There are various components included in the process. These components are Query Dispatcher, Optimization Engines, Classic Query Engine and SQL Query Engine, etc. Classic query engine handles all non-SQL queries, but SQL query engine won't handle logical files. Following is a simple diagram showing SQL Architecture: 30 | P a g e 4.2 SQL Commands: The standard SQL commands to interact with relational databases are CREATE, SELECT, INSERT, UPDATE, DELETE and DROP. These commands can be classified into groups based on their nature: Command CREATE Creates a new table, a view of a table, or other object in database ALTER Modifies an existing database object, such as a table. DROP Deletes an entire table, a view of a table or other object in the database. 4.2.1 Data Manipulation Language Command Description INSERT Creates a record UPDATE Modifies records DELETE Deletes records 4.2.2 DCL -Data Control Language: Command GRANT 31 | P a g e Description Gives a privilege to user REVOKE Takes back privileges granted from user 4.2.3 DQL -Data Query Language: Command Description SELECT Retrieves certain records from one or more tables 4.3SQL RDBMS Concepts What is RDBMS? RDBMS stands for Relational Database Management System. RDBMS is the basis for SQL and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access. A Relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as introduced by E. F. Codd. What is table? The data in RDBMS is stored in database objects called tables. The table is a collection of related data entries and it consists of columns and rows. Remember, a table is the most common and simplest form of data storage in a relational database. Following is the example of a CUSTOMERS table: +----+----------+-----+-----------+----------+ | ID | NAME | AGE | ADDRESS | SALARY | +----+----------+-----+-----------+----------+ | 1 | Tayo | 32 | Lagos | 2000.00 | | 2 | Tolu | 25 | Ogun | 1500.00 | | 3 | Funke | 23 | Ondo | 2000.00 | | 4 | Sola | 25 | Osun | 6500.00 | | 5 | Ahmed | 27 | Osun | 8500.00 | | 6 | Komal | 22 | Abia | 4500.00 | | 7 | Muffy | 24 | Lagos | 10000.00 | +----+----------+-----+-----------+----------+ 32 | P a g e What is field? Every table is broken up into smaller entities called fields. The fields in the CUSTOMERS table consist of ID, NAME, AGE, ADDRESS and SALARY. A field is a column in a table that is designed to maintain specific information about every record in the table. What is record or row? A record, also called a row of data, is each individual entry that exists in a table. For example, there are 7 records in the above CUSTOMERS table. Following is a single row of data or record in the CUSTOMERS table: +----+----------+-----+-----------+----------+ | 1 | Ahmed | 32 | Lagos | 2000.00 | +----+----------+-----+-----------+----------+ A record is a horizontal entity in a table. What is column? A column is a vertical entity in a table that contains all information associated with a specific field in a table. For example, a column in the CUSTOMERS table is ADDRESS, which represents location description and would consist of the following: +-----------+ | ADDRESS | +-----------+ | Lagos | | Ogun | | Abia | | Ekiti | | Oyo | +----+------+ What is NULL value? A NULL value in a table is a value in a field that appears to be blank, which means a field with a NULL value is a field with no value. It is very important to understand that a NULL value is different than a zero value or a field that contains spaces. A field with a NULL value is one that has been left blank during record creation. 4.5 Database Normalization Database normalization is the process of efficiently organizing data in a database. There are two reasons of the normalization process: make sense. Both of these are worthy goals as they reduce the amount of space a database consumes and ensure that data is logically stored. Normalization consists of a series of guidelines that help guide you in creating a good database structure. 33 | P a g e Normalization guidelines are divided into normal forms; think of form as the format or the way a database structure is laid out. 4.4.1 Normalisation forms The aim of normal forms is to organize the database structure so that it complies with the rules of first normal form, then second normal form, and finally third normal form. It's your choice to take it further and go to fourth normal form, fifth normal form, and so on, but generally speaking, third normal form is enough. First Normal Form First normal form (1NF) sets the very basic rules for an organized database: data items in a table. . First Rule of 1NF: You must define the data items. This means looking at the data to be stored, organizing the data into columns, defining what type of data each column contains, and finally putting related columns into their own table. For example, you put all the columns relating to locations of meetings in the Location table, those relating to members in the MemberDetails table, and so on. Second Rule of 1NF: The next step is ensuring that there are no repeating groups of data. Consider we have the following table CREATE TABLE CUSTOMERS( ID INT NOT NULL, NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL, ADDRESS CHAR (25), ORDERS VARCHAR(155) ); So if we populate this table for a single customer having multiple orders, then it would be something as follows: ID 100 NAME Sachin AGE 36 ADDRESS Lower West Side ORDERS Cannon XL200 100 Sachin 36 Lower West Battery XL- 34 | P a g e 100 Sachin 36 Side 200 Lower West Side Tripod Large But as per 1NF, we need to ensure that there are no repeating groups of data. So let us break above table into two parts and join them using a key as follows: CUSTOMERS table: CREATE TABLE CUSTOMERS( ID INT NOT NULL, NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL, ADDRESS CHAR (25), PRIMARY KEY (ID) ); This table would have the following record ID NAME AGE ADDRESS 100 Sachin 36 Lower West Side ORDERS table: CREATE TABLE ORDERS( ID INT NOT NULL, CUSTOMER_ID INT NOT NULL, ORDERS VARCHAR(155), PRIMARY KEY (ID) ); This table would have the following records: CUSTOMER_ID ORDERS Cannon XL-200 100 100 Battery XL-200 100 Tripod Large Third Rule of 1NF: The final rule of the first normal form, create a primary key for each table which we have already created. 35 | P a g e 4.5 SQL SYNTAX SQL is followed by unique set of rules and guidelines called Syntax. This tutorial gives you a quick start with SQL by listing all the basic SQL Syntax: All the SQL statements start with any of the keywords like SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW and all the statements end with a semicolon (;). Important point to be noted is that SQL is case insensitive, which means SELECT and select have same meaning in SQL statements, but MySQL makes difference in table names. So if you are working with MySQL, then you need to give table names as they exist in the database. SQL SELECT Statement: SELECT column1, column2....columnN FROM table_name; SQL DISTINCT Clause: SELECT DISTINCT column1, column2....columnN FROM table_name; SQL WHERE Clause: SELECT column1, column2....columnN FROM table_name WHERE CONDITION; SQL AND/OR Clause: SELECT column1, column2....columnN FROM table_name WHERE CONDITION-1 {AND|OR} CONDITION-2; SQL IN Clause: SELECT column1, column2....columnN FROM table_name WHERE column_name IN (val-1, val-2,...val-N); SQL BETWEEN Clause: SELECT column1, column2....columnN FROM table_name WHERE column_name BETWEEN val-1 AND val-2; SQL LIKEClause: SELECT column1, column2....columnN FROM table_name WHERE column_name LIKE { PATTERN }; SQL ORDER BY Clause: SELECT column1, column2....columnN FROM table_name WHERE CONDITION ORDER BY column_name {ASC|DESC}; 36 | P a g e SQL GROUP BY Clause: SELECT SUM(column_name) FROM table_name WHERE CONDITION GROUP BY column_name; SQL HAVING Clause: SELECT SUM(column_name) FROM table_name WHERE CONDITION GROUP BY column_name HAVING (arithematic function condition); SQL DROP TABLE Statement: DROP TABLE table_name; SQL ALTER TABLE Statement: ALTER TABLE table_name {ADD|DROP|MODIFY} column_name {data_ype}; SQL UPDATE Statement: UPDATE table_name SET column1 = value1, column2 = value2....columnN=valueN [ WHERE CONDITION ];: 4.6 SQL DATA TYPES SQL data type is an attribute that specifies type of data of any object. Each column, variable and expression has related data type in SQL. You would use these data types while creating your tables. You would choose a particular data type for a table column based on your requirement. SQL Server offers six categories of data types for your use: Exact Numeric Data Types: DATA TYPE Bigint FROM 9,223,372,036,854,775,80 8 TO 9,223,372,036,854,775,80 7 Int -2,147,483,648 2,147,483,647 Smallint -32,768 32,767 Tinyint 0 255 37 | P a g e Bit 0 1 Decimal -10^38 +1 10^38 -1 Numeric -10^38 +1 10^38 -1 Money 922,337,203,685,477.580 8 +922,337,203,685,477.58 07 Smallmoney -214,748.3648 +214,748.3647 Real -3.40E + 38 3.40E + 38 Date and Time Data Types: DATA TYPE Datetime FROM Jan 1, 1753 TO Dec 31, 9999 Smalldatetime Jan 1, 1900 Jun 6, 2079 Date Stores a date like June 30, 1991 Time Stores a time of day like 12:30PM 4.7 SQL Operators What is an Operator in SQL? An operator is a reserved word or a character used primarily in an SQL statement's WHERE clause to perform operation(s), such as comparisons and arithmetic operations. Operators are used to specify conditions in an SQL statement and to serve as conjunctions for multiple conditions in a statement. 38 | P a g e SQL Arithmetic Operators: Assume variable a holds 10 and variable b holds 20, then: Operator + - * / % Description Addition - Adds values on either side of the operator Subtraction - Subtracts right hand operand from left hand operand Multiplication - Multiplies values on either side of the operator Division - Divides left hand operand by right hand operand Modulus - Divides left hand operand by right hand operand and returns remainder Example a + b will give 30 a - b will give -10 a * b will give 200 b / a will give 2 b % a will give 0 SQL Comparison Operators: Assume variable a holds 10 and variable b holds 20, then: Operator = != <> > < >= 39 | P a g e Description Checks if the values of two operands are equal or not, if yes then condition becomes true. Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. Example (a = b) is not true. (a != b) is true. (a <> b) is true. (a > b) is not true. (a < b) is true. (a >= b) is not true CHAPTER FIVE 5.0 INTRODUCTION TO JAVA With the invention of microprocessors,the world is scientifically developed with sophisticated equipmwents,systems and devices. Microprocessors are used in computers,televisions and fax machines. Even the hand-held devices such as pagers,PDAs(Personal Digital Assistant) and cell phones make use of microprocessors. All these electronic devices are helpful because of their communication capabilities. With the increasing capabilities and decreasing cost of information processing and network technologies,the network is growing rapidlyfor transmitting information through electronic systems. Internet is the network of networks between different types of computers located at different places to transmit information. Information can to any places in the world quickly at a cheaper rate through the Internet. Thus,the internet has made the world a global village for information exchange. The emerging infrastructure of electronic devices and interconnected computer network create an environment that presents new challenges to software industries. For this emerging computing environment,Java process to be a well – suited programming language. It is found suitable for networked environments involving a great variety of computer and devices Java has many characteristic that have contributed to its popularity: Platform independence: Many languages are compatible with one platform. Java was specifically designed so that it would run on any computer regardless if it was running Windows,Linux,Mac,Unix or any of the other operating systems. Simple and easy to use: Java’s creator tried to design it so code could be writtenefficiently and easily. Multi-functional: Java can produce many applications from command line programs to applets to Swing Windows Java does have some drawbacks. Since it has automated garbage collection,it can tend to use more memory than the other similar languages. There are oftenimplementation differences on different platforms which have led to Java being described as a “write once,test everywhere”system. Lastly,since it uses an abstract “virtual machine” a generic Java program doesn’t have access to the Native API’s on a system directly. None of these issues are fatal but it can mean that Java isnt appropriate choice for a particular piece of software. 40 | P a g e 5.1 Java Virtual Machine (JVM) & its Architecture JVM is a engine that provides runtime environment to drive the Java Code or applications. It converts Java bytecode into machines language. JVM is a part of JRE(Java Run Environment). It stands for Java Virtual Machine In other programming languages, the compiler produces machine code for a particular system. However, Java compiler produces code for a Virtual Machine known as Java Virtual Machine. First, Java code is complied into bytecode. This bytecode gets interpreted on different machines Between host system and Java source, Bytecode is an intermediary language. JVM is responsible for allocating memory space. Writing a Program The easiest way to write a simple program is with a text editor. So, using the text editor of your choice, create a text file with the following text, and be sure to name the text file ExampleProgram.java. Java programs are case sensitive, so if you type the code in yourself, pay particular attention to the capitalization. //A Very Simple Example class ExampleProgram { public static void main(String[] args){ 41 | P a g e System.out.println("I'm a Simple Program"); } } Compiling the Program A program has to be converted to a form the Java VM can understand so any computer with a Java VM can interpret and run the program. Compiling a Java program means taking the programmer-readable text in your program file (also called source code) and converting it to bytecodes, which are platform-independent instructions for the Java VM. The Java compiler is invoked at the command line on Unix and DOS shell operating systems as follows: javac ExampleProgram.java Note: Part of the configuration process for setting up the Java platform is setting the class path. The class path can be set using either the -classpath option with the javac compiler command and java interpreter command, or by setting the CLASSPATH environment variable. You need to set the class path to point to the directory where the ExampleProgram class is so the compiler and interpreter commands can find it. Interpreting and Running the Program Once your program successfully compiles into Java bytecodes, you can interpret and run applications on any Java VM, or interpret and run applets in any Web browser with a Java VM built in such as Netscape or Internet Explorer. Interpreting and running a Java program means invoking the Java VM byte code interpreter, which converts the Java byte codes to platform-dependent machine codes so your computer can understand and run the program. The Java interpreter is invoked at the command line on Unix and DOS shell operating systems as follows: java ExampleProgram At the command line, you should see: I'm a Simple Program 5.2 CLASS Create a Class A Class is like an object constructor, or a "blueprint" for creating objects. To create a class, use the keyword class: 42 | P a g e MyClass.java Create a class called "MyClass" with a variable x: public class MyClass { int x = 5; } JAVA MAIN METHOD public static void main(String[] args) Java main method is the entry point of any java program. Its syntax is always public static void main(String[] args). You can only change the name of String array argument, for example you can change args to myStringArgs. Also String array argument can be written as String... args or String args[]. public This is the access modifier of the main method. It has to be public so that java runtime can execute this method. Remember that if you make any method non-public then it’s not allowed to be executed by any program, there are some access restrictions applied. So it means that the main method has to be public. Let’s see what happens if we define the main method as non-public. static 43 | P a g e When java runtime starts, there is no object of the class present. That’s why the main method has to be static so that JVM can load the class into memory and call the main method. If the main method won’t be static, JVM would not be able to call it because there is no object of the class is present. void Java programming mandates that every method provide the return type. Java main method doesn’t return anything, that’s why it’s return type is void. This has been done to keep things simple because once the main method is finished executing, java program terminates. So there is no point in returning anything, there is nothing that can be done for the returned object by JVM. If we try to return something from the main method, it will give compilation error as an unexpected return value. For example, if we have the main method like below. main This is the name of java main method. It’s fixed and when we start a java program, it looks for the main method. String[] args Java main method accepts a single argument of type String array. This is also called as java command line arguments. 5.3 VARIABLES IN JAVA A variable is a name given to a memory location. It is the basic unit of storage in a program. The value stored in a variable can be changed during program execution. A variable is only a name given to a memory location, all the operations done on the variable effects that memory location. In Java, all the variables must be declared before use. How to declare variables? We can declare variables in java as follows: 44 | P a g e datatype: Type of data that can be stored in this variable. variable_name: Name given to the variable. value: It is the initial value stored in the variable. 5.4 Decision Making in Java (if, if-else) Decision Making in programming is similar to decision making in real life. In programming also we face some situations where we want a certain block of code to be executed when some condition is fulfilled. A programming language uses control statements to control the flow of execution of program based on certain conditions. These are used to cause the flow of execution to advance and branch based on changes to the state of a program. 5.4.1 IF Statement if statement is the most simple decision making statement. It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true then a block of statement is executed otherwise not. Example: // Java program to illustrate If statement class IfDemo { public static void main(String args[]) { int i = 10; if (i > 15) System.out.println("10 is less than 15"); // This statement will be executed // as if considers one statement by default System.out.println("I am Not in if"); } } Output: I am Not in if 45 | P a g e 5.4.2 IF/Else Statement The if statement alone tells us that if a condition is true it will execute a block of statements and if the condition is false it won’t. But what if we want to do something else if the condition is false. Here comes the else statement. We can use the else statement with if statement to execute a block of code when the condition is false. Syntax: if (condition) { // Executes this block if // condition is true } else { // Executes this block if // condition is false } 5.5 Concept of Array in Java An array is a collection of similar data types. Array is a container object that hold values of homogenous type. It is also known as static data structure because size of an array must be specified at the time of its declaration. An array can be either primitive or reference type. It gets memory in heap area. Index of array starts from zero to size-1. Features of Array It is always indexed. Index begins from 0. It is a collection of similar data types. It occupies a contiguous memory location. 5.5.1 Array Declaration Syntax : datatype[] identifier; or 46 | P a g e datatype identifier[]; Both are valid syntax for array declaration. But the former is more readable. Example : int[ ] arr; char[ ] arr; short[ ] arr; long[ ] arr; 5.5.2 Initialization of Array new operator is used to initialize an array. Example : int[] arr = new int[10]; //this creates an empty array named arr of integer type whose size is 10. or int[] arr = {10,20,30,40,50}; //this creates an array named arr whose elements are given. Accessing array element As mention ealier array index starts from 0. To access nth element of an array. Syntax arrayname[n-1]; Example : To access 4th element of a given array int[ ] arr = {10,20,30,40}; System.out.println("Element at 4th place" + arr[3]); The above code will print the 4th element of array arr on console. Note: To find the length of an array, we can use the following syntax: array_name.length. There are no braces infront of length. Its not length(). 5.5.3 How to Loop Through An Array in Java with Example There are multiple ways to loop over an array in Java e.g. you can use a for loop, an enhanced for loop, a while loop or a do-while loop. Since while and do-while needs a condition to terminate they often depend upon the content of the array e.g. stop when the current element is null or even or odd etc. If you just want to iterate over an array to access each element e.g. loop over an array and print each entry then you should use either for loop or the enhanced for loop. The traditional for loop uses a counter and allows you to iterate until the last element is reached i.e. counter is equal to the length of the array while enhanced for loop maintains that counter internally, allowing you to iterate without worrying about counts. This results in clean code and it also eliminates the possibility of one-off errors. 47 | P a g e package hello; public class ArrayTester{ public static void main(String[] args) { // how to loop over an integer array int[] primes = {2, 3, 5, 7, 11, 13, 17}; // looping using for loop System.out.println("looping over an array using for loop"); for(int i=0; i< primes.length; i++){ System.out.println("current element is: " + primes[i]); } // looping using enhanced for loop of Java 5 System.out.println("looping over an array using enhanced for loop"); for(int number: primes){ System.out.println(number); } } } Output looping over an array using for loop current element is: 2 current element is: 3 current element is: 5 current element is: 7 current element is: 11 current element is: 13 current element is: 17 48 | P a g e 5.6 OBJECT It is a basic unit of Object Oriented Programming and represents the real life entities. A typical Java program creates many objects, which as you know, interact by invoking methods. An object consists of : State : It is represented by attributes of an object. It also reflects the properties of an object. Behavior : It is represented by methods of an object. It also reflects the response of an object with other objects. Identity : It gives a unique name to an object and enables one object to interact with other objects. Example of an object : dog Objects correspond to things found in the real world. For example, a graphics program may have objects such as “circle”, “square”, “menu”. An online shopping system might have objects such as “shopping cart”, “customer”, and “product”. 5.6.1 Declaring Objects (Also called instantiating a class) When an object of a class is created, the class is said to be instantiated. All the instances share the attributes and the behavior of the class. But the values of those attributes, i.e. the state are unique for each object. A single class may have any number of instances. 49 | P a g e As we declare variables like (type name;). This notifies the compiler that we will use name to refer to data whose type is type. With a primitive variable, this declaration also reserves the proper amount of memory for the variable. So for reference variable, type must be strictly a concrete class name. In general,we can’t create objects of an abstract class or an interface. Dog tuffy; 5.6.2 DOT OPERATOR The (.) operator is also known as member operator it is used to access the member of a package or a class. Example public class Sample { void display() { double d = 20.3; int i = (int)d; System.out.println(i); } public static void main(String args[]) { Sample s = new Sample(); s.display(); } } Output 20 5.6.3 References to Objects As you work with objects, it's important to understand references. A reference is an address that indicates where an object's variables and methods are stored. You aren't actually using objects when you assign an object to a variable or pass an object to a method as an argument. You aren't even using copies of the objects. Instead, you're using references to those objects 50 | P a g e The Full Text of ReferencesTest.java 1: import java.awt.Point; 2: 3: class ReferencesTest { 4: public static void main(String[] arguments) { 5: Point pt1, pt2; 6: pt1 = new Point(100, 100); 7: pt2 = pt1; 8: 9: pt1.x = 200; 10: pt1.y = 200; 11: System.out.println("Point1: " + pt1.x + ", " + pt1.y); 12: System.out.println("Point2: " + pt2.x + ", " + pt2.y); 13: } 14: } Here is this program's output: Point1: 200, 200 Point2: 200 5.7 METHODS A Java method is a collection of statements that are grouped together to perform an operation. When you call the System.out.println() method, for example, the system actually executes several statements in order to display a message on the console. Now you will learn how to create your own methods with or without return values, invoke a method with or without parameters, and apply method abstraction in the program design. Creating Method Considering the following example to explain the syntax of a method − Syntax public static int methodName(int a, int b) { // body } 51 | P a g e Here, public static − modifier int − return type methodName − name of the method a, b − formal parameters int a, int b − list of parameters Method definition consists of a method header and a method body. The same is shown in the following syntax − Syntax modifier returnType nameOfMethod (Parameter List) { // method body } The syntax shown above includes − modifier − It defines the access type of the method and it is optional to use. returnType − Method may return a value. nameOfMethod − This is the method name. The method signature consists of the method name and the parameter list. Parameter List − The list of parameters, it is the type, order, and number of parameters of a method. These are optional, method may contain zero parameters. method body − The method body defines what the method does with the statements. 5.8 JAVA CONSTRUCTORS Java Constructors A constructor in Java is a special method that is used to initialize objects. The constructor is called when an object of a class is created. It can be used to set initial values for object attributes. 52 | P a g e CHAPTER SIX 6.0 RECOMMENDATION AND CONCLUSION 6.1 Recommendation The SIWES unit together with the relevant departments should make tangible efforts to liaise with relevant industries, companies, and organisations to alleviate the difficulties often faced by the students in securing a placement for the industrial training Employers should also be encouraged to pay stipends to I.T students to increase their enthusiasm and motivation for work. The university officials should visit students often in order to know their challenges and success 6.2 Conclusion The Students Industrial Work Experience scheme (SIWES) has bridged the gap between academic theory and practical and has built a good degree of confidence especially in me. It has also given me a first-hand experience of the quality control analysis of water, the privilege to build interpersonal relationship with staffs and colleagues, ability to work as a team, ability to work both under and under no supervision. Similarly, it has been an eye opener to the importance of Civil Engineering nationwide and its status in the society. I can confidently say that the experience gained from this training is worthwhile. 53 | P a g e 54 | P a g e