This document contains a quiz on object-oriented programming concepts in Java. It includes multiple choice and short answer questions about relationships between classes like IS-A, HAS-A, and BEHAVES-LIKE. It also contains questions about Java keywords and syntax related to inheritance, interfaces, and access modifiers. The document provides class code examples and asks students to implement a Fraction class and design classes for planning an evening out using inheritance and instance variables.
FOR MORE CLASSES VISIT
tutorialoutletdotcom
NameFirstNamePhoneNumberTranslator.java
Coin.java
LastNameFirstNameCoinDriver.java
ModifiedCoin.java Note 1: Unless otherwise mentioned, you are asked to upload ONLY your java source files through
blackboard. Email submission is not accepted, because of confusion in grading.
FOR MORE CLASSES VISIT
tutorialoutletdotcom
NameFirstNamePhoneNumberTranslator.java
Coin.java
LastNameFirstNameCoinDriver.java
ModifiedCoin.java Note 1: Unless otherwise mentioned, you are asked to upload ONLY your java source files through
blackboard. Email submission is not accepted, because of confusion in grading.
Structure and Enumeration are used as value type in c#.Value type variables store their data on the stack memory.An enumeration is a set of named integer constants. An enumerated type is declared using the enum keyword. C# enumerations are value data type. In other words, enumeration contains its own values and cannot inherit or cannot pass inheritance.
C# - Constants and Literals. The constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal.
Structure and Enumeration are used as value type in c#.Value type variables store their data on the stack memory.An enumeration is a set of named integer constants. An enumerated type is declared using the enum keyword. C# enumerations are value data type. In other words, enumeration contains its own values and cannot inherit or cannot pass inheritance.
C# - Constants and Literals. The constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal.
100% Accurate and Updated dumps available for 1Z0-804 Exam-Java SE 7 Programmer II get 20% off on all dumps visit@https://www.troytec.com/1Z0-804-exams.html
Detailed presentation on Inheritance and interfaces in JAVA. Presentation includes suitable example for better understanding the concepts such as Overriding in java and also keywords such as FINAL and SUPER.
For more classes visit
www.snaptutorial.com
Question 1. 1. In addition to grouping functions together, a class also groups (Points : 3)
libraries.
math operations.
print statements.
variables.
Question 2. 2. Hiding data in a class is also called (Points : 3)
For more course tutorials visit
www.tutorialrank.com
Question 1. 1. In addition to grouping functions together, a class also groups (Points : 3)
libraries.
math operations.
print statements.
variables.
For more course tutorials visit
www.tutorialrank.com
Question 1. 1. In addition to grouping functions together, a class also groups (Points : 3)
libraries.
math operations.
print statements.
variables.
For more classes visit
www.snaptutorial.com
Question 1. 1. In addition to grouping functions together, a class also groups (Points : 3)
libraries.
math operations.
print statements.
For more classes visit
www.snaptutorial.com
Question 1. 1. In addition to grouping functions together, a class also groups (Points : 3)
libraries.
math operations.
print statements.
variables.
Question 2. 2. Hiding data in a class is also called (Points : 3)
encapsulation.
accessibility inversion.
For more classes visit
www.snaptutorial.com
Question 1. 1. In addition to grouping functions together, a class also groups (Points : 3)
libraries.
math operations.
print statements.
Question 1. 1. In addition to grouping functions together, a class also groups (Points : 3)
libraries.
math operations.
print statements.
variables.
Question 2. 2. Hiding data in a class is also called (Points : 3)
encapsulation.
accessibility inversion.
confusion culling.
redirection.
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
1. Object-Oriented Programming in Java
Quiz 1 Jan 10, 2001
Problem 1: Who wants to be a Java developer? (with apologies to Regis)
Fill in your answer in the space provided.
Question 1: Which is these word-pairs represents the IS-A relationship ( in English)?
A. duck/bird B. bird/fly
C. beak/bird D. bird/nest
Final Answer:
Question 2: Which is these pairs represents the HAS-A relationship?
A. bird/duck B. bird/fly
C. bird/beak D. bird/flying animal
Final Answer:
Question 3: Which is these pairs represents the BEHAVES-LIKE relationship?
A. bird/duck B. bird/fly
C. bird/beak D. bird/flying animal
Final Answer:
Question 4: Which phrase below best describes the relationship between Country and Capital?
A. IS-A B. HAS-A
C. USES D. BEHAVES-LIKE
Final Answer:
Question 5: Which Java technology best supports the IS-A relationship?
A. Inheritance B. Access Restriction
C. Strong Typing D. Garbage Collection
Final Answer:
Question 6: Which Java keyword is used to specify inheritance?
A. extends B. implements
C. public D. static
Final Answer:
1
2. Question 7: Which Java keyword is used to specify compliance with an interface?
A. extends B. implements
C. public D. static
Final Answer:
Question 8: Which Java keywords can not appear in a class declaration?
A. extends B. private
C. void D. abstract
Final Answer:
Question 9: Is it possible to use the techniques of object oriented programming in a language
that does not specifically support OOP?
A. Yes B. No
C. D.
Final Answer:
Question 10: Are private classes only for malicious corporations closely guarding their propri-etary
code?
A. Yes B. No
C. D.
Final Answer:
Question 11: Which Java keywords can not appear in instance variable definitions?
A. extends B. protected
C. int D. private
Final Answer:
Question 12: Which Java keywords can not appear in method definitions?
A. implements B. void
C. static D. private
Final Answer:
Question 13: Which of these fragments represents the HAS-A relationship between Foo and
Bar?
A. class Foo extends Bar{} B. class Foo implements Bar{ }
C. class Foo { private Bar mybar; } D. abstract class Bar extends Foo{ }
Final Answer:
2
3. Question 14: Which line of code in the following can be inserted in place of the comments, to
perform the initialization described by the comments?
public class T {
int r;
int s;
T(int x, int y) {
r = x;
s = y;
}
}
class S extends T {
int t;
public S(int x, int y, int z){
// insert here the code
// that would do the correct initialization
// r= x and s= y
t=z;
}
}
A. T(x, y); B. this(x, y);
C. super(x, y); D. super(x, y, z);
Final Answer:
Question 15: What do the ’public’ and ’private’ keywords relate to?
A. Typing B. Garbage Collection
C. Polymorphism D. Access Restriction
Final Answer:
Question 16: Which Java technologies most powerfully supports the programming concept of
“encapsulation”?
A. Container Classes B. Access Restriction
C. Garbage Collection D. Typing
Final Answer:
Question 17: Which Java technologies most powerfully support the programming concept of
“abstraction”?
A. Inheritance and Polymorphism B. Heap Allocation
C. Garbage Collection D. Applets
Final Answer:
3
4. Problem 2: Program Analysis: Short Answer
Question 1: What are the values of i,a, and b after the following code fragment runs.?
int i;
int a=1;
int b=0;
for(i=0;i<10;i++){
a = a * 2;
b++;
}
i =
a =
b =
Question 2: What is the value of a after the following code fragment runs?
int a=0;
while(true){
if(a > 20) break;
a = a+1;
}
a =
Question 3: What three lines will the following code print out when compiled and run?
public class Spindle{
public static void main(String[] args){
int[] a = new int[] {1,2,3,4};
int b = 5;
int c =6;
Fold.mutilate( a , b, c);
System.out.println( a[0]);
System.out.println( b);
System.out.println( c );
}
}
class Fold{
static void mutilate( int[] a, int b , int c) {
a[0] = 7;
b = 8;
c = 9;
}
}
line1:
line2:
line3:
4
5. Question 4: What does the class Test below print out if it is compiled and run?
public class Test
{
int x;
Test(String s){
this();
System.out.println(s);
System.out.println("This");
}
Test(int x){
this("is");
}
Test(){
System.out.println("a test.");
}
public static void main(String[] args)
{
int val = 2;
Test t = new Test(val);
}
}
Test prints out:
5
6. The next three short answer question use the following group of classes.
/**
* An interface with one method
*/
interface Face1{
public void bar();
}
/**
* A class with an accessor and method foo()
*/
class Class1{
private int size = 0;
private String name;
Class1(String name){
this.name = name;
}
public String getName(){
return(name);
}
public void foo(){
System.out.println(‘‘Class1.foo()’’);
}
}
/**
* A class inheriting from Class1
*/
class Class2 extends Class1 implements Face1{
int size = 0;
int x;
Class2(String name){
super(name);
}
public void foo(){
System.out.println(‘‘Class2.foo()’’);
}
public void bar(){
System.out.println(‘‘Class2.bar()’’);
}
}
6
7. Question 5: What does the following print out?
public class TestClass{
public static void main(String[] args){
Class1 c = new Class2(‘‘me’’);
c.foo();
}
}
Ans:
Question 6: What does the following print out?
public class TestClass{
public static void main(String[] args){
Class1 c = new Class1(‘‘me’’);
c.foo();
}
}
Ans:
Question 7: What does the following print out?
public class TestClass{
public static void main(String[] args){
Class2 c = new Class2(‘‘me’’);
System.out.println(c.getName());
}
}
Ans:
Question 8: What does the following print out?
public class TestClass{
public static void main(String[] args){
Face1 c = new Class2(‘‘me’’);
c.bar();
}
}
Ans:
7
8. Problem 3: Class Implementation
In this problem we ask you to implement part of a class Fraction, which represents fractions of
the form a/b where a and b are integers, (1/2, 4/6, 101/432. etc.). In the space below, complete the
class Fraction. Use int to store the numerator and denominator.
Include a constructor that initializes from a numerator and denominator.
Write an instance method for addition. [Hint: a/b + c/d = (ad + bc)/bd.]
Write a static method for multiplication. [Hint: a/b c/d = ac/bd.]
Write a static main() that allocates two Fractions, 1/2 and 3/4 and stores their sum in a third
variable.
(Be merciful to graders: please write clearly).
/**
* Class Fraction. Represent the fraction X/Y where X and Y are integers
*/
public class Fraction{
/**
* Your instance vars here
*/
/**
* Your constructor here
*/
Continued on next page
8
9. /**
* Your add method here
*/
/**
* Your static mult method here
*/
/**
* Your static main here
*/
}
9
10. Problem 4: OOP Design
You are designing an OO program to help people plan an evening out. It is proposed that the
following classes be used. Add inheritance ( extends phrases ) and instance variables to show the
IS-A and HAS-A relationships between these classes. Do not introduce any additional classes or and
instance variables of any basic type. [Note: By Business, we mean anything that would appear in
the Yellow Pages].
class Address
{
}
class Business
{
}
class City
{
}
class Restaurant
{
}
class Theater
{
}
10