MISCALLENOUS Flashcards

1
Q

What are behaviors in OOP?

A

Behaviors are the tasks that an object performs and how it operates. The behavior of an object is defined by its methods,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are attributes in OOP?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe the Java development cycle.

A
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Using code segments, describe what an interface is as used in OOP.

A

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; 
         } 
      }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Briefly explain at least 4 object-oriented design concepts.

A

Encapsulation
Abstraction
Inheritance
Polymorphism

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

List at least 3 types of errors that a Java programmer might encounter.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Differentiate between an abstract class and a concrete class.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Describe what a static method is and give its features. Give one circumstance where Java uses static methods
in its applications

A

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[])
    {}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
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. (
A
//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();
   }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Why we need an abstract class?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Using code samples, explain any THREE differences between method
overloading and method overriding

A

It occurs within the class. It is performed in two classes with inheritance relationships.

  1. Method overloading may or may not require inheritance. Method overriding always needs inheritance.
  2. In method overloading, methods must have the same name and different signatures. In method overriding, methods must have the same name and same signature.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly