<E4MsW>

156 阅读3分钟

MathWorks 2020:

  1. BQ

    • Multitasking, how to handle
    • Project not going as expected
    • Take risk or not, how to handle
    • Work with others, mentors
    • How to deal with disagreement
    • Proud project
  2. Data Structure & Programming

    • OOP and advantages:

      1. Object-Oriented Programming, this is a programming mode, it means the programming is around data and objects instead of logic and actions, "objects" are instances of class, objects have attributes and methods of a class.

      2. easy to understand; easy to maintain; good reusability of code; good flexibility of code

    • how to import in Java and what if import same twice?

      use import key word, program runs just fine, it won't import twice

    • implement queue with two stacks

    • what is java generics?

      generics allows you to customerize the type of a method or class to whatever type. for e.g., to deal with adding two numbers, you have int, float, double. Instead, you write:

      public static E genericsTest(E num){ return num; }

      allows you to deal with multiple types for method or class without writing the similar code for each type

    • what is inheritance?

      one class can inherit from another class, sub class will have all non-private method and attributes from father class.

      public class father{

      } public class sub extends father{

      }

      can:

      B inherits from A, C inherits from B

      B, C inherits from A

      can not:

      C inherits from A and B (diamond problem: D inherits from C, there are same methods in both A and B, which one should D inherits from?)

      Use Super key word to access immediate parent class:

      super.methodname();

      final key word: this class can't be inherited or this mehtod can not be written by sub classes.

    • what is polymorphism?

      Polymorphism means "many forms", it means to have different functions in different situation, just like functions keys on keyboard, same key but with different functions in different pages.

      B,C,D inherits from A and have same function but performs differently when is called.

    • Interface, abstract class, and difference?

      abstract class is not able to be have instance, it means to be inherited, like fly

      interface is not a class, but the way to implement is similar as class; it doesn't have constructors, all methods must be abstract methods.

      interface:

        public interface interface1{
            
        }
        public interface interface2{
            
        }
        
        public class subclass1 implements interface1, interface2{
            
        }
      

      abstract class:

        public abstract class abclass1{
            
        }
        
        public class subclass2 extends abclass1{
            
        }
      

      difference:

        - a class may implements many interfaces, but can only inherit one abstract class
        
        - methods: in interface all methods are abstract, but not all abstract in abstract class
      
    • Final, Finally, Finalize: final: unchangeable variable, not overrideable method, not inheritable class finally: used in try & catch block, code in this block must be excuted finalize: used in garbage collection

    • Mutex:

      an object that allows different threads to share same memory in turns, basically is a lock.

    • difference between int and Integer:

      int is one of the primitive data types, Integer is a wrapper class of int

      when to use Integer: Integer default null, int default 0, when you want to have a difference between untaken test and 0 points for test

    • Java pass by value, object is passed by value of its reference。

    • Can java garbage collection manually? how

      yes, by System.gc().

    • JDK vs JRE

      JDK: Java Development Kit, includes JRE

      JRE: Java Runtime Environmentk

    • static key word

      static key word is something like global in java, it means the object with static key word would always exist instead of relying on some instances.

      also it means the methods can not be override

    • override vs overload:

      override can not change the input parameters or return value, overload can change them

    • super key word

      1. super. to refer immediate parent class instance
      2. super. to invoke immediate parent class method
      3. super() to invoke immediate parent class constructor
    • == vs .equals()

      1. == is an operator and .equals() is a function
      2. == checks the reference (memory location) and .equals() checks the expression value
    • hashmap vs hashtable

      1. hashmap allows null keys and null values, which is not allowed in hashtable
      2. hashmap is able to iterate key set.
      3. hashtable is sychronized not hashmap, so hashmap is preferred in single-thread environments

      when hashtable key is recollected but not values, the memory will leak

    • pointer: a memory space stores another memory space address

    • time complexity of insertion and deletion between dynamic array and linkedlist

      Linkedlist: insert O(1), delete O(1), not like remove, thats O(n) both insert/delete from beginning

      dynamic array/arraylist: insert O(n), delete O(n)

  3. Coding

    • OOD:
      1. ATM
      2. Reservation