{"id":196,"date":"2024-07-30T06:50:38","date_gmt":"2024-07-30T06:50:38","guid":{"rendered":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/chapter\/introduction-4\/"},"modified":"2026-03-16T14:30:55","modified_gmt":"2026-03-16T14:30:55","slug":"introduction-4","status":"publish","type":"chapter","link":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/chapter\/introduction-4\/","title":{"raw":"Introduction","rendered":"Introduction"},"content":{"raw":"<div class=\"introduction\">\n\nThis chapter explores abstraction and how it applies to algorithms, classes, and data structures.\u00a0 [pb_glossary id=\"240\"]Abstraction [\/pb_glossary]enables Java [pb_glossary id=\"241\"]generics[\/pb_glossary], which allows us to reuse code that would be essentially the same, save for the exact data type being used or stored.\u00a0 Several Java data structures are explored, including [pb_glossary id=\"232\"]Queues [\/pb_glossary]and [pb_glossary id=\"242\"]Stacks[\/pb_glossary].\n\n&nbsp;\n<div class=\"textbox textbox--learning-objectives\"><header class=\"textbox__header\">\n<p class=\"textbox__title\">Learning Objectives<\/p>\n\n<\/header>\n<div class=\"textbox__content\">\n<ul>\n \t<li>Explain polymorphism as it is implemented in the Java Programming language<\/li>\n \t<li>Introduce the comparable Interface<\/li>\n \t<li>Describe the differences between an Interface and Abstract class<\/li>\n<\/ul>\n<\/div>\n<\/div>\nBy the end of this chapter, you should be able to answer the following questions:\n<ul>\n \t<li>What is the purpose of abstraction?<\/li>\n \t<li>How does abstraction support Object Oriented Programming?<\/li>\n \t<li>Under what circumstances is it better to use an abstract class over an interface?<\/li>\n \t<li>Under what circumstances is it better to use an interface over an abstract class?<\/li>\n<\/ul>\n<\/div>","rendered":"<div class=\"introduction\">\n<p>This chapter explores abstraction and how it applies to algorithms, classes, and data structures.\u00a0 <a class=\"glossary-term\" aria-haspopup=\"dialog\" aria-describedby=\"definition\" href=\"#term_196_240\">Abstraction <\/a>enables Java <a class=\"glossary-term\" aria-haspopup=\"dialog\" aria-describedby=\"definition\" href=\"#term_196_241\">generics<\/a>, which allows us to reuse code that would be essentially the same, save for the exact data type being used or stored.\u00a0 Several Java data structures are explored, including <a class=\"glossary-term\" aria-haspopup=\"dialog\" aria-describedby=\"definition\" href=\"#term_196_232\">Queues <\/a>and <a class=\"glossary-term\" aria-haspopup=\"dialog\" aria-describedby=\"definition\" href=\"#term_196_242\">Stacks<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<div class=\"textbox textbox--learning-objectives\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">Learning Objectives<\/p>\n<\/header>\n<div class=\"textbox__content\">\n<ul>\n<li>Explain polymorphism as it is implemented in the Java Programming language<\/li>\n<li>Introduce the comparable Interface<\/li>\n<li>Describe the differences between an Interface and Abstract class<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<p>By the end of this chapter, you should be able to answer the following questions:<\/p>\n<ul>\n<li>What is the purpose of abstraction?<\/li>\n<li>How does abstraction support Object Oriented Programming?<\/li>\n<li>Under what circumstances is it better to use an abstract class over an interface?<\/li>\n<li>Under what circumstances is it better to use an interface over an abstract class?<\/li>\n<\/ul>\n<\/div>\n<div class=\"glossary\"><span class=\"screen-reader-text\" id=\"definition\">definition<\/span><template id=\"term_196_240\"><div class=\"glossary__definition\" role=\"dialog\" data-id=\"term_196_240\"><div tabindex=\"-1\"><p>Abstraction refers, in general, to the idea of providing a simplified or higher level interface to a complex system. It is closely related to the idea of a \"black box.\" Abstraction makes it possible to understand or use a system, while ignoring some of the details of what actually goes on in the system. Control abstractions make it possible to implement algorithms on a higher level than machine language. Abstraction is a fundamental concept in computer science.<\/p>\n<\/div><button><span aria-hidden=\"true\">&times;<\/span><span class=\"screen-reader-text\">Close definition<\/span><\/button><\/div><\/template><template id=\"term_196_241\"><div class=\"glossary__definition\" role=\"dialog\" data-id=\"term_196_241\"><div tabindex=\"-1\"><p>Writing code that will work with various types of data, rather than with just a single type of data. The Java Collection Framework, and classes that use similar techniques, are examples of generic programming in Java.<\/p>\n<\/div><button><span aria-hidden=\"true\">&times;<\/span><span class=\"screen-reader-text\">Close definition<\/span><\/button><\/div><\/template><template id=\"term_196_232\"><div class=\"glossary__definition\" role=\"dialog\" data-id=\"term_196_232\"><div tabindex=\"-1\"><p>A data structure consisting of a list of items, where items can only be added at one end and removed at the opposite end of the list.<\/p>\n<\/div><button><span aria-hidden=\"true\">&times;<\/span><span class=\"screen-reader-text\">Close definition<\/span><\/button><\/div><\/template><template id=\"term_196_242\"><div class=\"glossary__definition\" role=\"dialog\" data-id=\"term_196_242\"><div tabindex=\"-1\"><p>A data structure consisting of a list of items where items can only be added and removed at one end of the list, which is known as the \"top\" of the stack. Adding an item to a stack is called \"pushing,\" and removing an item is called \"popping.\" The term stack also refers to the stack of activation records that is used to implement subroutine calls.<\/p>\n<\/div><button><span aria-hidden=\"true\">&times;<\/span><span class=\"screen-reader-text\">Close definition<\/span><\/button><\/div><\/template><\/div>","protected":false},"author":1,"menu_order":1,"template":"","meta":{"pb_show_title":"","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[49],"contributor":[],"license":[],"class_list":["post-196","chapter","type-chapter","status-publish","hentry","chapter-type-numberless"],"part":195,"_links":{"self":[{"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/chapters\/196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":2,"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/chapters\/196\/revisions"}],"predecessor-version":[{"id":256,"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/chapters\/196\/revisions\/256"}],"part":[{"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/parts\/195"}],"metadata":[{"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/chapters\/196\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/chapter-type?post=196"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/wp\/v2\/contributor?post=196"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/wp\/v2\/license?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}