MISCALLENOUS Flashcards
What are behaviors in OOP?
Behaviors are the tasks that an object performs and how it operates. The behavior of an object is defined by its methods,
What are attributes in OOP?
Attributes are data members inside a class or an object that represent the different features of the class. They can also be referred to as characteristics of the class that can be accessed from other objects or differentiate a class from other classes.
Describe the Java development cycle.
- Requirement Phase
During this phase, the client states requirements, specifications, expectations, and any other special requirement related to the product or software. The requirement includes how the product will be used and who will use the product to determine the load of operations. - Design Phase
The design phase includes a detailed analysis of new software according to the requirement phase. This is the high priority phase in the development life cycle of a system because the logical designing of the system is converted into physical designing. - Build /Development Phase
After the successful completion of the requirement and design phase, the next step is to implement the design into the development of a software system. - Testing Phase
Testing is the last step of completing a software system. In this phase, after getting the developed GUI and back-end combination, it is tested against the requirements stated in the requirement phase. - Deployment/ Deliver Phase
When software testing is completed with a satisfying result, and there are no remaining issues in the working of the software, it is delivered to the customer for their use. - Maintenance
The maintenance phase is the last and long-lasting phase of SDLC because it is the process which continues until the software’s life cycle comes to an end.
Using code segments, describe what an interface is as used in OOP.
An interface is a programming structure/syntax that allows the computer to enforce certain properties on an object (class). For example, say we have a car class and a scooter class and a truck class. Each of these three classes should have a start_engine() action. How the “engine is started” for each vehicle is left to each particular class, but the fact that they must have a start_engine action is the domain of the interface.
package { public interface Vehicle { // NO data VARIABLES are allowed in an interface // only function PROTOTYPES
/** * Comments... * Anything that wants to be a "Vehicle" must, implement this function */ function start_engine() : void;
} }
Briefly explain at least 4 object-oriented design concepts.
Encapsulation
Abstraction
Inheritance
Polymorphism
List at least 3 types of errors that a Java programmer might encounter.
Syntax errors
These are errors where the compiler finds something wrong with your program, and you can’t even try to execute it. For example, you may have incorrect punctuation, or may be trying to use a variable that hasn’t been declared.
Runtime errors
If there are no syntax errors, Java may detect an error while your program is running. You will get an error message telling you the kind of error, and a stack trace that tells not only where the error occurred, but also what other method or methods you were in. For example,
Logic errors
A logic error, or bug, is when your program compiles and runs, but does the wrong thing. The Java system, of course, has no idea what your program is supposed to do, so it provides no additional information to help you find the error.
Differentiate between an abstract class and a concrete class.
An abstract class is declared using abstract modifier. A concrete class is note declared using abstract modifier.
An abstract class cannot be directly instantiated using the new keyword. A concrete class can be directly instantiated using the new keyword.
An abstract class may or may not contain abstract methods. A concrete class cannot contain an abstract method.
An abstract class cannot be declared as final. A concrete class can be declared as final.
Abstract-Implement an interface is possible by not providing implementations of all of the interface’s methods. For this a child class is needed. Concrete- Easy implementation of all of the methods in the interface.
Describe what a static method is and give its features. Give one circumstance where Java uses static methods
in its applications
The static keyword is used to construct methods that will exist regardless of whether or not any instances of the class are generated. Any method that uses the static keyword is referred to as a static method.
Features of static method:
-A static method in Java is a method that is part of a class rather than an instance of that class.
-Every instance of a class has access to the method.
Static methods have access to class variables (static variables) without using the class’s object (instance).
-Only static data may be accessed by a static method. –It is unable to access data that is not static (instance variables).
-In both static and non-static methods, static methods can be accessed directly.
The main method in a java class is always static eg public static void main(String args[]) {}
An abstract class Triangle has sideA, sideB and sideC as attributes. It has an abstract getPerimeter() method. Declare a concrete class RightTriangle to inherit the class Triangle. (
//abstract parent class abstract class Animal{ //abstract method public abstract void sound(); } //Dog class extends Animal class public class Dog extends Animal{
public void sound(){ System.out.println("Woof"); } public static void main(String args[]){ Animal obj = new Dog(); obj.sound(); } }
Why we need an abstract class?
So when we know that all the animal child classes will and should override this method, then there is no point to implement this method in parent class. Thus, making this method abstract would be the good choice as by making this method abstract we force all the sub classes to implement this method( otherwise you will get compilation error), also we need not to give any implementation to this method in parent class.
Using code samples, explain any THREE differences between method
overloading and method overriding
It occurs within the class. It is performed in two classes with inheritance relationships.
- Method overloading may or may not require inheritance. Method overriding always needs inheritance.
- In method overloading, methods must have the same name and different signatures. In method overriding, methods must have the same name and same signature.
State and explain any TWO advantages of using JavaFX as compared to java.
swing or java.awt Application Programming Interfaces (API’s) when creating user
interfaces
FX offers consistent support for MVC, while Swing’s MVC support is not equal across all platforms.
The JavaFX declarative style not only makes your code more readable, but it makes it more concise too.