CSC 113 Tutorial QUIZ I.

Slides:



Advertisements
Similar presentations
Inheritance. Many objects have a hierarchical relationship –Examples: zoo, car/vehicle, card game, airline reservation system Inheritance allows software.
Advertisements

INHERITANCE BASICS Reusability is achieved by INHERITANCE
Mock test review Revision of Activity Diagrams for Loops,
Starting Classes and Methods. Objects have behaviors In old style programming, you had: –data, which was completely passive –functions, which could manipulate.
1 Chapter 7 l Inheritance Basics l Programming with Inheritance l Dynamic Binding and Polymorphism Inheritance.
25-Jun-15 Starting Classes and Methods. Objects have behaviors In old style programming, you had: data, which was completely passive functions, which.
Vocabulary Key Terms polymorphism - Selecting a method among many methods that have the same name. subclass - A class that inherits variables and methods.
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Viswanathan Inheritance and Polymorphism Course Lecture Slides 2 nd June 2010 “ We are.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Java Quiz Bowl A fun review of the Java you should know from CMPT 201 If you don’t know the answers - this week is for you to study up!
Inheritence Put classes into a hierarchy derive a new class based on an existing class with modifications or extensions. Avoiding duplication and redundancy.
RIT Computer Science Dept. Goals l Inheritance l Modifiers: private, public, protected l Polymorphism.
Created by Terri Street Copyright, 2000  1,000,0001,000,000  500,000500,000  250,000250,000  125,000125,000  64,00064,000  32,00032,000  16,00016,000.
Parameters… Classes Cont Mrs. C. Furman October 13, 2008.
Java Classes. Consider this simplistic class public class ProjInfo {ProjInfo() {System.out.println("This program computes factorial of number"); System.out.println("passed.
RECITATION 4. Classes public class Student { } Data Members public class Student { private String name; public String id; }
C# C1 CSC 298 Elements of C# code (part 1). C# C2 Style for identifiers  Identifier: class, method, property (defined shortly) or variable names  class,
COP 2800 Lake Sumter State College Mark Wilson, Instructor.
MIT AITI 2004 – Lecture 13 Abstract Classes and Interfaces.
Methods. Methods also known as functions or procedures. Methods are a way of capturing a sequence of computational steps into a reusable unit. Methods.
Java Class Structure. Class Structure package declaration import statements class declaration class (static) variable declarations* instance variable.
ICBT  Basura Ramanayaka  Eshani werapitiya  Hasitha Dananjaya.
Classes and Objects CS177 Rec 10. Announcements Project 4 is posted ◦ Milestone due on Nov. 12. ◦ Final submission due on Nov. 19. Exam 2 on Nov. 4 ◦
Recitation 8 User Defined Classes Part 2. Class vs. Instance methods Compare the Math and String class methods that we have used: – Math.pow(2,3); – str.charAt(4);
CS 2430 Day 9. Announcements Quiz 2.1 this Friday Program 2 due this Friday at 3pm (grace date Sunday at 10pm)
Classes - Intermediate
Object Oriented Programming I ( ) Dr. Adel hamdan Part 03 (Week 4) Dr. Adel Hamdan Date Created: 7/10/2011.
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
Lecture 6: Methods MIT-AITI Kenya © 2005 MIT-Africa Internet Technology Initiative In this lecture, you will learn… What a method is Why we use.
COMP Inheritance and Polymorphism Yi Hong June 09, 2015.
COP INTERMEDIATE JAVA Inheritance, Polymorphism, Interfaces.
BY:- TOPS Technologies
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Introduction to java (class and object). Programming languages: –Easier to understand than CPU instructions –Needs to be translated for the CPU to understand.
Topic: Classes and Objects
Summary prepared by Kirk Scott
Examples of Classes & Objects
Arrays 3/4 By Pius Nyaanga.
Class Structure 15-Jun-18.
Some Eclipse shortcuts
Inheritance and Polymorphism
Object Oriented Programming
University of Central Florida COP 3330 Object Oriented Programming
Week 8 Lecture -3 Inheritance and Polymorphism
Inheritance Chapter 5.
CS1316: Representing Structure and Behavior
Michele Weigle - COMP 14 - Spr 04 Catie Welsh April 11, 2011
Classes & Objects: Examples
CS1316: Representing Structure and Behavior
Inheritance.
METHOD OVERRIDING in JAVA
Assignment 7 User Defined Classes Part 2
CS18000: Problem Solving and Object-Oriented Programming
S.VIGNESH Assistant Professor, SECE
JAVA Constructors.
Assessment – Java Basics: Part 1
Chapter 10: Method Overriding and method Overloading
Constructors, GUI’s(Using Swing) and ActionListner
Final Jim Brucker.
Chapter 9 Objects and Classes Part 01
Method Overriding and method Overloading
Chapter 11 Inheritance and Polymorphism Part 1
Arrays 3/4 June 3, 2019 ICS102: The course.
Chapter 6 Arrays.
Chapter 11 Inheritance and Encapsulation and Polymorphism
Topics OOP Review Inheritance Review Abstract Classes
Classes and Methods 15-Aug-19.
CS 240 – Advanced Programming Concepts
Presentation transcript:

CSC 113 Tutorial QUIZ I

Write your name and date. Instructions Take out a paper. Write your name and date. Type the question number next to the answer i.e Question 1 ) A Each question will be shown on the board a max of 3 mins, act fast. Good luck

An object is an instance of a __________. Fill in the space An object is an instance of a __________. The keyword __________ is required to declare a class. ________ is used to create an object.

Choose one of the following 4) Given the declaration Student [ ] x = new Student[10]; which of the following statement is most accurate? x contains an array of ten int values. x contains an array of ten objects of the Student type. x contains a reference to an array and each element in the array can hold a reference to a Student object. x contains a reference to an array and each element in the array can hold a Student object.

Choose one of the following 5) When invoking a method with an object argument, ___________ is passed. the contents of the object a copy of the object the reference of the object the object is copied, then the reference of the copied object

Choose one of the following 6) Variables that are shared by every instances of a class are __________. public variables private variables instance variables class variables

Choose FROM the following 7) Which of the following statements are true? A default constructor is provided automatically if no constructors are explicitly declared in the class. At least one constructor must always be defined explicitly. Every class has a default constructor. The default constructor is a no-arg constructor.

Choose FROM the following 8) Which of the following is incorrect? int[] a = new int[2]; int[] a = new int(2); int a = new int[2]; int a() = new int[2];

Choose FROM the following 9) Which of the following statements are true? A default constructor is provided automatically if no constructors are explicitly declared in the class. At least one constructor must always be defined explicitly. Every class has a default constructor. The default constructor is a no-arg constructor.

Choose FROM the following 10) Which of the following statements are true? A subclass is a subset of a superclass. A subclass is usually extended to contain more functions and more detailed information than its superclass. "class A extends B" means A is a subclass of B. "class A extends B" means B is a subclass of A.

Choose FROM the following public class Student {   String name; public Student(String name) {     this.name = name; }   void print( ) {     System.out.println(name); } } public class Test {   public static void main(String[] args) {     Student s = new Student( );     s.print( );   } } 11) The program has a compilation error because class Student does not have getName( ). The program has a compilation error because class Student does not have a default constructor. The program compiles and runs fine and prints nothing. The program would compile and run if you change Student s = new Student( ) to Student s = new Student("5").

Choose FROM the following 12) What is the output of the following code?   A. 0 1 2 Error public class Parent {   int id = 1;  public void print() {     System.out.println(id);   } } public class Child extends Parent {   int id = 2; } public class Test1 {   public static void main(String[] args) {     Child c = new Child();     c.print( );

Write the following program 13) Write a class with a main method that shows a menu and ask the user to enter a choice to do the following: Print your Name. Show your Student ID. Exit. Don’t forget to use default.